]> git.meshlink.io Git - catta/commitdiff
* remove stale UNIX sockets before creating new ones
authorLennart Poettering <lennart@poettering.net>
Tue, 21 Jun 2005 23:45:41 +0000 (23:45 +0000)
committerLennart Poettering <lennart@poettering.net>
Tue, 21 Jun 2005 23:45:41 +0000 (23:45 +0000)
* make sure to flush outbound records after conflict detection

git-svn-id: file:///home/lennart/svn/public/avahi/trunk@141 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe

avahi-core/server.c
avahi-daemon/simple-protocol.c

index a020f6432f0fdfa8b866038588d6d7ca899689a6..356a917cec8a9296a8117f990c257cc563f5419f 100644 (file)
@@ -615,7 +615,6 @@ static void handle_query_packet(AvahiServer *s, AvahiDnsPacket *p, AvahiInterfac
     
 fail:
     avahi_record_list_flush(s->record_list);
-
 }
 
 static void handle_response_packet(AvahiServer *s, AvahiDnsPacket *p, AvahiInterface *i, const AvahiAddress *a) {
@@ -653,6 +652,12 @@ static void handle_response_packet(AvahiServer *s, AvahiDnsPacket *p, AvahiInter
             
         avahi_record_unref(record);
     }
+
+    /* If the incoming response contained a conflicting record, some
+       records have been scheduling for sending. We need to flush them
+       here. */
+    if (!avahi_record_list_empty(s->record_list))
+        avahi_server_generate_response(s, i, NULL, NULL, 0, FALSE);
 }
 
 static AvahiLegacyUnicastReflectSlot* allocate_slot(AvahiServer *s) {
index 8bd8da4403588ee27654092dda4813ed0cdcd1d3..c41e07cd224a502862feb115f72e790db653d573 100644 (file)
@@ -386,6 +386,13 @@ int simple_protocol_setup(GMainContext *c) {
     sa.sun_family = AF_LOCAL;
     strncpy(sa.sun_path, UNIX_SOCKET, sizeof(sa.sun_path)-1);
 
+    /* We simply remove existing UNIX sockets under this name. The
+       Avahi daemons makes sure that it runs only once on a host,
+       therefore sockets that already exist are stale and may be
+       removed without any ill effects */
+
+    unlink(UNIX_SOCKET);
+    
     if (bind(server->fd, &sa, sizeof(sa)) < 0) {
         avahi_log_warn("bind(): %s", strerror(errno));
         goto fail;