From dfdebdd97909ebbefac4834d440847fe58daafb2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rafa=C5=82=20Mi=C5=82ecki?= Date: Wed, 8 Feb 2017 18:04:27 +0100 Subject: [PATCH] Don't call dns_reply_a from service_reply MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This simplifies code without changing any behavior. Having this call in service_reply required checking two conditions and was making code flow harder to follow. There are 2 more service_reply calls in the project: 1) In service_announce_services where we iterate over &services and every element of this list has "service" field filled. It means match argument was never NULL and dns_reply_a was never called from there. 2) In parse_question which also receives some name (there is a proper check in the dns_handle_packet). No call there neither. So after all there was only 1 place that was indeed calling dns_reply_a. Signed-off-by: Rafał Miłecki Acked-by: John Crispin --- dns.c | 4 +++- service.c | 6 ------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/dns.c b/dns.c index 7ca705e..aac1de1 100644 --- a/dns.c +++ b/dns.c @@ -360,8 +360,10 @@ parse_question(struct interface *iface, char *name, struct dns_question *q) switch (q->type) { case TYPE_ANY: - if (!strcmp(name, mdns_hostname_local)) + if (!strcmp(name, mdns_hostname_local)) { service_reply(iface, NULL, announce_ttl); + dns_reply_a(iface, announce_ttl); + } break; case TYPE_PTR: diff --git a/service.c b/service.c index a3a5bb4..f45784b 100644 --- a/service.c +++ b/service.c @@ -153,12 +153,6 @@ service_reply(struct interface *iface, const char *match, int ttl) vlist_for_each_element(&services, s, node) service_reply_single(iface, s, match, ttl, 0); - - if (match) - return; - - if (ttl) - dns_reply_a(iface, ttl); } void -- 2.11.0