]> git.meshlink.io Git - catta/blobdiff - avahi-core/multicast-lookup.c
Remove an invalid optimization in avahi_simple_poll_run(). (Closes #132)
[catta] / avahi-core / multicast-lookup.c
index 4f04ab86b98515df122166457eccfba756533ff9..c3afcb0094e8fd3391ae3ed15e194dfefcb6a9df 100644 (file)
 #include <config.h>
 #endif
 
+#include <stdlib.h>
+
 #include <avahi-common/malloc.h>
+#include <avahi-common/timeval.h>
 
-#include "server.h"
+#include "internal.h"
 #include "browse.h"
 #include "socket.h"
 #include "log.h"
 #include "hashmap.h"
 #include "multicast-lookup.h"
+#include "rr-util.h"
 
 struct AvahiMulticastLookup {
     AvahiMulticastLookupEngine *engine;
@@ -71,7 +75,7 @@ static void all_for_now_callback(AvahiTimeEvent *e, void* userdata) {
     avahi_time_event_free(l->all_for_now_event);
     l->all_for_now_event = NULL;
 
-    l->callback(l->engine, l->interface, l->protocol, AVAHI_BROWSER_ALL_FOR_NOW, AVAHI_LOOKUP_CALLBACK_MULTICAST, NULL, l->userdata);
+    l->callback(l->engine, l->interface, l->protocol, AVAHI_BROWSER_ALL_FOR_NOW, AVAHI_LOOKUP_RESULT_MULTICAST, NULL, l->userdata);
 }
 
 AvahiMulticastLookup *avahi_multicast_lookup_new(
@@ -83,7 +87,7 @@ AvahiMulticastLookup *avahi_multicast_lookup_new(
     void *userdata) {
     
     AvahiMulticastLookup *l, *t;
-    struct timeval ctime;
+    struct timeval tv;
         
     assert(e);
     assert(AVAHI_IF_VALID(interface));
@@ -109,12 +113,14 @@ AvahiMulticastLookup *avahi_multicast_lookup_new(
 
     AVAHI_LLIST_PREPEND(AvahiMulticastLookup, lookups, e->lookups, l);
 
-    avahi_querier_add_for_all(e->server, interface, protocol, l->key, &ctime);
+    avahi_querier_add_for_all(e->server, interface, protocol, l->key, &tv);
+    l->queriers_added = 1;
 
-    /* add a second */
-    avahi_timeval_add(&ctime, 1000000);
+    /* Add a second */
+    avahi_timeval_add(&tv, 1000000);
 
-    l->all_for_now_event = avahi_time_event_new(e->server->time_event_queue, &ctime, all_for_now_callback, l);
+    /* Issue the ALL_FOR_NOW event one second after the querier was initially created */
+    l->all_for_now_event = avahi_time_event_new(e->server->time_event_queue, &tv, all_for_now_callback, l);
     
     return l;
 }
@@ -208,7 +214,7 @@ static void* scan_cache_callback(AvahiCache *c, AvahiKey *pattern, AvahiCacheEnt
         cbdata->interface->hardware->index,
         cbdata->interface->protocol,
         AVAHI_BROWSER_NEW,
-        AVAHI_LOOKUP_CALLBACK_CACHED|AVAHI_LOOKUP_CALLBACK_MULTICAST,
+        AVAHI_LOOKUP_RESULT_CACHED|AVAHI_LOOKUP_RESULT_MULTICAST,
         e->record,
         cbdata->userdata);
 
@@ -295,7 +301,7 @@ void avahi_multicast_lookup_engine_notify(AvahiMulticastLookupEngine *e, AvahiIn
             continue;
 
         if (avahi_interface_match(i, l->interface, l->protocol))
-            l->callback(e, i->hardware->index, i->protocol, event, AVAHI_LOOKUP_CALLBACK_MULTICAST, record, l->userdata);
+            l->callback(e, i->hardware->index, i->protocol, event, AVAHI_LOOKUP_RESULT_MULTICAST, record, l->userdata);
     }
 
 
@@ -310,7 +316,7 @@ void avahi_multicast_lookup_engine_notify(AvahiMulticastLookupEngine *e, AvahiIn
             
             if ((key = avahi_key_new_cname(l->key))) {
                 if (avahi_key_equal(record->key, key))
-                    l->callback(e, i->hardware->index, i->protocol, event, AVAHI_LOOKUP_CALLBACK_MULTICAST, record, l->userdata);
+                    l->callback(e, i->hardware->index, i->protocol, event, AVAHI_LOOKUP_RESULT_MULTICAST, record, l->userdata);
 
                 avahi_key_unref(key);
             }