mdnsd: the service is ignoring questions
authorJohn Crispin <john@phrozen.org>
Mon, 19 Dec 2016 12:06:15 +0000 (13:06 +0100)
committerJohn Crispin <john@phrozen.org>
Mon, 19 Dec 2016 12:06:15 +0000 (13:06 +0100)
When a question is incoming the service was incorrectly resettig the
query timeout regardless of it being the right service. This causes
the code to never answer the questions it is being asked.

Reported-by: Cristian Morales Vega <cristian@samknows.com>
Signed-off-by: John Crispin <john@phrozen.org>
service.c

index fe6e5a9..8d514c2 100644 (file)
--- a/service.c
+++ b/service.c
@@ -107,7 +107,7 @@ service_add_srv(struct service *s, int ttl)
 
 #define TOUT_LOOKUP    60
 
 
 #define TOUT_LOOKUP    60
 
-static int
+static time_t
 service_timeout(struct service *s)
 {
        time_t t = monotonic_time();
 service_timeout(struct service *s)
 {
        time_t t = monotonic_time();
@@ -115,9 +115,7 @@ service_timeout(struct service *s)
        if (t - s->t <= TOUT_LOOKUP)
                return 0;
 
        if (t - s->t <= TOUT_LOOKUP)
                return 0;
 
-       s->t = t;
-
-       return 1;
+       return t;
 }
 
 void
 }
 
 void
@@ -154,8 +152,10 @@ service_reply_single(struct interface *iface, struct service *s, const char *mat
 {
        const char *host = service_name(s->service);
        char *service = strstr(host, "._");
 {
        const char *host = service_name(s->service);
        char *service = strstr(host, "._");
+       time_t t = service_timeout(s);
+
 
 
-       if (!force && (!s->active || !service || !service_timeout(s)))
+       if (!force && (!s->active || !service || !t))
                return;
 
        service++;
                return;
 
        service++;
@@ -163,6 +163,8 @@ service_reply_single(struct interface *iface, struct service *s, const char *mat
        if (match && strcmp(match, s->service))
                return;
 
        if (match && strcmp(match, s->service))
                return;
 
+       s->t = t;
+
        dns_init_answer();
        service_add_ptr(service_name(s->service), ttl);
        dns_send_answer(iface, service);
        dns_init_answer();
        service_add_ptr(service_name(s->service), ttl);
        dns_send_answer(iface, service);