cache: improve update call by doing a full refresh probe
[project/mdnsd.git] / cache.c
diff --git a/cache.c b/cache.c
index 9df051d59072502a6ca5985314fce5a497b7c3c9..384487aa3d8b7a604acae5c637bfd9703ca6803f 100644 (file)
--- a/cache.c
+++ b/cache.c
@@ -143,11 +143,11 @@ void
 cache_update(void)
 {
        struct interface *iface;
 cache_update(void)
 {
        struct interface *iface;
-       struct cache_service *s;
 
 
-       vlist_for_each_element(&interfaces, iface, node)
-               avl_for_each_element(&services, s, avl)
-                       dns_send_question(iface, NULL, s->entry, TYPE_PTR, 0);
+       vlist_for_each_element(&interfaces, iface, node) {
+               dns_send_question(iface, NULL, C_DNS_SD, TYPE_ANY, 0);
+               dns_send_question(iface, NULL, C_DNS_SD, TYPE_PTR, 0);
+       }
 }
 
 static struct cache_service*
 }
 
 static struct cache_service*
@@ -382,7 +382,8 @@ void cache_answer(struct interface *iface, struct sockaddr *from, uint8_t *base,
 }
 
 void
 }
 
 void
-cache_dump_records(struct blob_buf *buf, const char *name, int array)
+cache_dump_records(struct blob_buf *buf, const char *name, int array,
+                  const char **hostname)
 {
        struct cache_record *r, *last, *next;
        const char *txt;
 {
        struct cache_record *r, *last, *next;
        const char *txt;
@@ -454,8 +455,11 @@ cache_dump_records(struct blob_buf *buf, const char *name, int array)
                        break;
 
                case TYPE_SRV:
                        break;
 
                case TYPE_SRV:
-                       if (r->rdata)
+                       if (r->rdata) {
                                blobmsg_add_string(buf, "host", (char *)r->rdata + sizeof(struct dns_srv_data));
                                blobmsg_add_string(buf, "host", (char *)r->rdata + sizeof(struct dns_srv_data));
+                               if (hostname)
+                                       *hostname = (char *)r->rdata + sizeof(struct dns_srv_data);
+                       }
                        if (r->port)
                                blobmsg_add_u32(buf, "port", r->port);
                        break;
                        if (r->port)
                                blobmsg_add_u32(buf, "port", r->port);
                        break;