]> git.meshlink.io Git - catta/commitdiff
core: Bug fixes for cleanup code
authorLennart Poettering <lennart@poettering.net>
Sat, 14 Nov 2009 01:43:37 +0000 (02:43 +0100)
committerLennart Poettering <lennart@poettering.net>
Sat, 14 Nov 2009 01:43:37 +0000 (02:43 +0100)
Patch contributed by "oc3an".

http://avahi.org/ticket/267

avahi-core/announce.c
avahi-core/entry.c
avahi-core/server.c

index a77fbb698874dedfbdd27f8c5745e4ba20899fb1..d0fd598d94cbaca07432690ac8709be6584a9e41 100644 (file)
@@ -376,7 +376,7 @@ static int is_duplicate_entry(AvahiServer *s, AvahiEntry *e) {
 
     for (i = avahi_hashmap_lookup(s->entries_by_key, e->record->key); i; i = i->by_key_next) {
 
-        if (i == e)
+        if ((i == e) || (i->dead))
             continue;
 
         if (!avahi_record_equal_no_ttl(i->record, e->record))
index 55c9ea29d99804c3cdd972d0a4ce2206b1095950..749fae5a4bce6adff4fa5333e39c2b1385ac6c99 100644 (file)
@@ -1087,6 +1087,8 @@ void avahi_s_entry_group_free(AvahiSEntryGroup *g) {
     
     g->server->need_group_cleanup = 1;
     g->server->need_entry_cleanup = 1;
+
+    avahi_cleanup_dead_entries(g->server);
 }
 
 static void entry_group_commit_real(AvahiSEntryGroup *g) {
@@ -1166,6 +1168,8 @@ void avahi_s_entry_group_reset(AvahiSEntryGroup *g) {
     g->n_probing = 0;
 
     avahi_s_entry_group_change_state(g, AVAHI_ENTRY_GROUP_UNCOMMITED);
+
+    avahi_cleanup_dead_entries(g->server);
 }
 
 int avahi_entry_is_commited(AvahiEntry *e) {
index 6efc6779e2afb09d79dd034d20c57eaba3a1c0b9..8955af93ed1af1625272204934692abeb2591460 100644 (file)
@@ -1009,13 +1009,6 @@ static void dispatch_legacy_unicast_packet(AvahiServer *s, AvahiDnsPacket *p) {
     avahi_dns_packet_set_field(p, AVAHI_DNS_FIELD_ID, slot->id);
 }
 
-static void cleanup_dead(AvahiServer *s) {
-    assert(s);
-
-    avahi_cleanup_dead_entries(s);
-    avahi_browser_cleanup(s);
-}
-
 static void mcast_socket_event(AvahiWatch *w, int fd, AvahiWatchEvent events, void *userdata) {
     AvahiServer *s = userdata;
     AvahiAddress dest, src;
@@ -1048,7 +1041,7 @@ static void mcast_socket_event(AvahiWatch *w, int fd, AvahiWatchEvent events, vo
 
         avahi_dns_packet_free(p);
 
-        cleanup_dead(s);
+        avahi_cleanup_dead_entries(s);
     }
 }
 
@@ -1071,7 +1064,7 @@ static void legacy_unicast_socket_event(AvahiWatch *w, int fd, AvahiWatchEvent e
         dispatch_legacy_unicast_packet(s, p);
         avahi_dns_packet_free(p);
 
-        cleanup_dead(s);
+        avahi_cleanup_dead_entries(s);
     }
 }