From: Lennart Poettering Date: Mon, 16 May 2005 02:08:57 +0000 (+0000) Subject: fix unicast known answer suppresion X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=7ef880c32da573ba044cde87ae99a98a6038b7d1;p=catta fix unicast known answer suppresion git-svn-id: file:///home/lennart/svn/public/avahi/trunk@73 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe --- diff --git a/avahi-core/server.c b/avahi-core/server.c index e80b0c4..6366dd8 100644 --- a/avahi-core/server.c +++ b/avahi-core/server.c @@ -416,8 +416,7 @@ static void handle_query(AvahiServer *s, AvahiDnsPacket *p, AvahiInterface *i, c if (!(key = avahi_dns_packet_consume_key(p, &unicast_response))) { g_warning("Packet too short (1)"); - avahi_record_list_flush(s->record_list); - return; + goto fail; } avahi_packet_scheduler_incoming_query(i->scheduler, key); @@ -425,9 +424,6 @@ static void handle_query(AvahiServer *s, AvahiDnsPacket *p, AvahiInterface *i, c avahi_key_unref(key); } - if (!avahi_record_list_empty(s->record_list)) - avahi_server_generate_response(s, i, p, a, port, legacy_unicast); - /* Known Answer Suppression */ for (n = avahi_dns_packet_get_field(p, AVAHI_DNS_FIELD_ANCOUNT); n > 0; n --) { AvahiRecord *record; @@ -435,11 +431,13 @@ static void handle_query(AvahiServer *s, AvahiDnsPacket *p, AvahiInterface *i, c if (!(record = avahi_dns_packet_consume_record(p, &unique))) { g_warning("Packet too short (2)"); - return; + goto fail; } - if (handle_conflict(s, i, record, unique, a)) + if (handle_conflict(s, i, record, unique, a)) { avahi_packet_scheduler_incoming_known_answer(i->scheduler, record, a); + avahi_record_list_drop(s->record_list, record); + } avahi_record_unref(record); } @@ -451,7 +449,7 @@ static void handle_query(AvahiServer *s, AvahiDnsPacket *p, AvahiInterface *i, c if (!(record = avahi_dns_packet_consume_record(p, &unique))) { g_warning("Packet too short (3)"); - return; + goto fail; } if (record->key->type != AVAHI_DNS_TYPE_ANY) @@ -459,6 +457,15 @@ static void handle_query(AvahiServer *s, AvahiDnsPacket *p, AvahiInterface *i, c avahi_record_unref(record); } + + if (!avahi_record_list_empty(s->record_list)) + avahi_server_generate_response(s, i, p, a, port, legacy_unicast); + + return; + +fail: + avahi_record_list_flush(s->record_list); + } static void handle_response(AvahiServer *s, AvahiDnsPacket *p, AvahiInterface *i, const AvahiAddress *a) {