]> git.meshlink.io Git - catta/blobdiff - avahi-core/server.c
* fix local conflict detection algorithm
[catta] / avahi-core / server.c
index ca5da5d1161940cc06b3f94d5264efbdf9850a1f..235247a66bbf3b40c100e84ee4b49f62c7aa72d7 100644 (file)
@@ -35,6 +35,7 @@
 #include <avahi-common/domain.h>
 #include <avahi-common/timeval.h>
 #include <avahi-common/malloc.h>
+#include <avahi-common/error.h>
 
 #include "server.h"
 #include "iface.h"
@@ -1202,10 +1203,14 @@ static void register_stuff(AvahiServer *s) {
     assert(s);
 
     server_set_state(s, AVAHI_SERVER_REGISTERING);
+    s->n_host_rr_pending ++;  /** Make sure that the state isn't changed tp AVAHI_SERVER_RUNNING too early */
+
     register_hinfo(s);
     register_browse_domain(s);
     avahi_update_host_rrs(s->monitor, 0);
 
+    s->n_host_rr_pending --;
+    
     if (s->n_host_rr_pending == 0)
         server_set_state(s, AVAHI_SERVER_RUNNING);
 }
@@ -1301,7 +1306,7 @@ static int setup_sockets(AvahiServer *s) {
     return 0;
 }
 
-AvahiServer *avahi_server_new(AvahiPoll *poll_api, const AvahiServerConfig *sc, AvahiServerCallback callback, void* userdata, int *error) {
+AvahiServer *avahi_server_new(const AvahiPoll *poll_api, const AvahiServerConfig *sc, AvahiServerCallback callback, void* userdata, int *error) {
     AvahiServer *s;
     int e;
     
@@ -1467,15 +1472,14 @@ static int check_record_conflict(AvahiServer *s, AvahiIfIndex interface, AvahiPr
         if ((flags & AVAHI_ENTRY_ALLOWMUTIPLE) && (e->flags & AVAHI_ENTRY_ALLOWMUTIPLE) )
             continue;
 
-        if (interface <= 0 ||
-            e->interface <= 0 ||
-            e->interface == interface ||
-            protocol == AVAHI_PROTO_UNSPEC ||
-            e->protocol == AVAHI_PROTO_UNSPEC ||
-            e->protocol == protocol)
+        if ((interface <= 0 ||
+             e->interface <= 0 ||
+             e->interface == interface) &&
+            (protocol == AVAHI_PROTO_UNSPEC ||
+             e->protocol == AVAHI_PROTO_UNSPEC ||
+             e->protocol == protocol))
 
             return -1;
-
     }
 
     return 0;