#include <stdio.h>
#include <time.h>
-#include <uci.h>
-#include <uci_blob.h>
-
#include <libubus.h>
#include <libubox/vlist.h>
#include <libubox/uloop.h>
#define TOUT_LOOKUP 60
-static int
+static time_t
service_timeout(struct service *s)
{
- time_t t = time(NULL);
+ time_t t = monotonic_time();
if (t - s->t <= TOUT_LOOKUP)
return 0;
- s->t = t;
-
- return 1;
+ return t;
}
void
{
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++;
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);