Hi,

Attached is a patch which fixes two issues in the avahi server.

1. is_duplicate_entry was matching against a dead entries. This causes problems where goodbyes are sometimes not sent because we (incorrectly) thought there was a duplicate entry. 2. avahi_s_entry_group_free and avahi_s_entry_group_reset now call avahi_cleanup_dead_entries because it can be a long time before the cleanup is triggered from a mcast_socket_event or legacy_unicast_socket_event. This causes excessive memory usage in some situations.

I have also removed the cleanup_dead function from avahi-core/server.c and replaced calls to it with avahi_cleanup_dead_entries as avahi_cleanup_dead_entries already calls avahi_browser_cleanup. The extra function call was redundant.

Thanks,

-Patrick
diff --git a/avahi-core/announce.c b/avahi-core/announce.c
index a77fbb6..d0fd598 100644
--- a/avahi-core/announce.c
+++ b/avahi-core/announce.c
@@ -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))
diff --git a/avahi-core/entry.c b/avahi-core/entry.c
index 2529485..8ac1da4 100644
--- a/avahi-core/entry.c
+++ b/avahi-core/entry.c
@@ -1088,6 +1088,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) {
@@ -1167,6 +1169,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) {
diff --git a/avahi-core/server.c b/avahi-core/server.c
index 85279b4..08f0104 100644
--- a/avahi-core/server.c
+++ b/avahi-core/server.c
@@ -1012,13 +1012,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;
@@ -1051,7 +1044,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);
     }
 }
 
@@ -1074,7 +1067,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);
     }
 }
 
_______________________________________________
avahi mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/avahi

Reply via email to