From f7e3b4fab6ba1bc98c6dbe859ccdef4fde6c5db2 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sat, 14 Nov 2009 02:43:37 +0100 Subject: [PATCH] core: Bug fixes for cleanup code Patch contributed by "oc3an". http://avahi.org/ticket/267 --- avahi-core/announce.c | 2 +- avahi-core/entry.c | 4 ++++ avahi-core/server.c | 11 ++--------- 3 files changed, 7 insertions(+), 10 deletions(-) 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 55c9ea2..749fae5 100644 --- a/avahi-core/entry.c +++ b/avahi-core/entry.c @@ -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) { diff --git a/avahi-core/server.c b/avahi-core/server.c index 6efc677..8955af9 100644 --- a/avahi-core/server.c +++ b/avahi-core/server.c @@ -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); } } -- 2.39.5