Don't call dns_reply_a from service_reply
authorRafał Miłecki <rafal@milecki.pl>
Wed, 8 Feb 2017 17:04:27 +0000 (18:04 +0100)
committerRafał Miłecki <rafal@milecki.pl>
Thu, 9 Feb 2017 08:09:43 +0000 (09:09 +0100)
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 <rafal@milecki.pl>
Acked-by: John Crispin <john@phrozen.org>
dns.c
service.c

diff --git a/dns.c b/dns.c
index 7ca705ea416653099bde9a3329c81119d5bb9bae..aac1de1e5be6ef572db94a2a3d6ce603c0bdaed9 100644 (file)
--- 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:
index a3a5bb49be452382d803b56d3a315f923f1faf85..f45784b69eb428690f539c7558a152abdad43d61 100644 (file)
--- 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