X-Git-Url: http://git.meshlink.io/?a=blobdiff_plain;f=avahi-core%2Fbrowse.c;h=5fd3a011b55f2f218ccdb3e7d11fe1dcbac1a4e5;hb=3073103812f0ea376582eb0ff1479945a847b361;hp=a133c62bdcc5603b39a2c5814115cbd0c4af0c99;hpb=bb14e0a8aa3173c8a6d80b1a9c8b300a452ee9f1;p=catta diff --git a/avahi-core/browse.c b/avahi-core/browse.c index a133c62..5fd3a01 100644 --- a/avahi-core/browse.c +++ b/avahi-core/browse.c @@ -36,7 +36,7 @@ #include "log.h" #include "querier.h" -#define AVAHI_MAX_LOOKUPS_PER_BROWSER 15 +#define AVAHI_LOOKUPS_PER_BROWSER_MAX 15 struct AvahiSRBLookup { AvahiSRecordBrowser *record_browser; @@ -79,7 +79,6 @@ static void transport_flags_from_domain(AvahiServer *s, AvahiLookupFlags *flags, *flags |= AVAHI_LOOKUP_USE_WIDE_AREA; } - static AvahiSRBLookup* lookup_new( AvahiSRecordBrowser *b, AvahiIfIndex interface, @@ -93,7 +92,7 @@ static AvahiSRBLookup* lookup_new( assert(AVAHI_IF_VALID(interface)); assert(AVAHI_PROTO_VALID(protocol)); - if (b->n_lookups >= AVAHI_MAX_LOOKUPS_PER_BROWSER) + if (b->n_lookups >= AVAHI_LOOKUPS_PER_BROWSER_MAX) /* We don't like cyclic CNAMEs */ return NULL; @@ -180,6 +179,21 @@ static AvahiSRBLookup *lookup_find( return NULL; } +static void browser_cancel(AvahiSRecordBrowser *b) { + assert(b); + + if (b->root_lookup) { + lookup_unref(b->root_lookup); + b->root_lookup = NULL; + } + + if (b->defer_time_event) { + avahi_time_event_free(b->defer_time_event); + b->defer_time_event = NULL; + } +} + + static void lookup_wide_area_callback( AvahiWideAreaLookupEngine *e, AvahiBrowserEvent event, @@ -266,6 +280,9 @@ static void lookup_multicast_callback( /* It's a normal record, so let's call the user callback */ assert(avahi_key_equal(b->key, l->key)); + if (avahi_server_is_record_local(b->server, interface, protocol, r)) + flags |= AVAHI_LOOKUP_RESULT_LOCAL; + b->callback(b, interface, protocol, event, r, flags, b->userdata); } break; @@ -408,7 +425,7 @@ static void lookup_handle_cname(AvahiSRBLookup *l, AvahiIfIndex interface, Avahi static void lookup_drop_cname(AvahiSRBLookup *l, AvahiIfIndex interface, AvahiProtocol protocol, AvahiLookupFlags flags, AvahiRecord *r) { AvahiKey *k; - AvahiSRBLookup *n; + AvahiSRBLookup *n = NULL; AvahiRList *rl; assert(r->key->clazz == AVAHI_DNS_CLASS_IN); @@ -469,7 +486,7 @@ static void defer_callback(AvahiTimeEvent *e, void *userdata) { b->flags & AVAHI_LOOKUP_USE_WIDE_AREA ? AVAHI_LOOKUP_RESULT_WIDE_AREA : AVAHI_LOOKUP_RESULT_MULTICAST, b->userdata); - avahi_s_record_browser_cancel(b); + browser_cancel(b); return; } @@ -493,7 +510,7 @@ void avahi_s_record_browser_restart(AvahiSRecordBrowser *b) { assert(b); assert(!b->dead); - avahi_s_record_browser_cancel(b); + browser_cancel(b); /* Request a new iteration of the cache scanning */ if (!b->defer_time_event) { @@ -550,20 +567,6 @@ AvahiSRecordBrowser *avahi_s_record_browser_new( return b; } -void avahi_s_record_browser_cancel(AvahiSRecordBrowser *b) { - assert(b); - - if (b->root_lookup) { - lookup_unref(b->root_lookup); - b->root_lookup = NULL; - } - - if (b->defer_time_event) { - avahi_time_event_free(b->defer_time_event); - b->defer_time_event = NULL; - } -} - void avahi_s_record_browser_free(AvahiSRecordBrowser *b) { assert(b); assert(!b->dead); @@ -571,13 +574,13 @@ void avahi_s_record_browser_free(AvahiSRecordBrowser *b) { b->dead = 1; b->server->need_browser_cleanup = 1; - avahi_s_record_browser_cancel(b); + browser_cancel(b); } void avahi_s_record_browser_destroy(AvahiSRecordBrowser *b) { assert(b); - avahi_s_record_browser_cancel(b); + browser_cancel(b); AVAHI_LLIST_REMOVE(AvahiSRecordBrowser, browser, b->server->record_browsers, b);