A service consists of 3 entries PTR/TXT/SRV. PTR/TXT have 4500s time to live (AVAHI_DEFAULT_TTL), but SRV (which contains ip/port number) has only 120s (AVAHI_DEFAULT_TTL_HOST_NAME). When unplugging the cable, -- shutdown of avahi would flush caches properly -- , the SRV entry will expire sooner than PTR/TXT. With the SRV entry missing, resolving will fail and not be restarted. Even if the network is restored and a new a new SRV entry created in the local cache, resolving is not retried, nor is the client noticed that resolving should be retried
Signed-off-by: Andreas Fenkart <afenk...@gmail.com> --- avahi-utils/avahi-browse.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/avahi-utils/avahi-browse.c b/avahi-utils/avahi-browse.c index 4101895..6ab1181 100644 --- a/avahi-utils/avahi-browse.c +++ b/avahi-utils/avahi-browse.c @@ -202,6 +202,8 @@ static void service_resolver_callback( assert(r); assert(i); + assert(i->resolver == r); + i->resolver = NULL; switch (event) { case AVAHI_RESOLVER_FOUND: { @@ -236,13 +238,21 @@ static void service_resolver_callback( case AVAHI_RESOLVER_FAILURE: - fprintf(stderr, _("Failed to resolve service '%s' of type '%s' in domain '%s': %s\n"), name, type, domain, avahi_strerror(avahi_client_errno(client))); + if (avahi_client_errno(client) == AVAHI_ERR_TIMEOUT) { + if (!(i->resolver = avahi_service_resolver_new(client, interface, protocol, name, type, domain, AVAHI_PROTO_UNSPEC, 0, service_resolver_callback, i))) { + fprintf(stderr, _("Failed to allocate new resolver for service '%s' of type '%s' in domain '%s': %s\n"), name, type, domain, avahi_strerror(avahi_client_errno(client))); + } + + n_resolving++; + fprintf(stderr, _("Failed to resolve service '%s' of type '%s' in domain '%s': %s retry\n"), name, type, domain, avahi_strerror(avahi_client_errno(client))); + } else { + fprintf(stderr, _("Failed to resolve service '%s' of type '%s' in domain '%s': %s\n"), name, type, domain, avahi_strerror(avahi_client_errno(client))); + } break; } - avahi_service_resolver_free(i->resolver); - i->resolver = NULL; + avahi_service_resolver_free(r); assert(n_resolving > 0); n_resolving--; -- 2.1.1 _______________________________________________ avahi mailing list avahi@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/avahi