diff options
| author | Felix Fietkau | 2025-05-28 21:50:50 +0000 |
|---|---|---|
| committer | Felix Fietkau | 2025-05-28 21:52:59 +0000 |
| commit | 083be33749b17468993fbc40e0646c1b0690e837 (patch) | |
| tree | 2ade56cbefb359aca6876ae92ee31ad9ea2832e8 | |
| parent | 0ce73d80dc0c3996eca0b73c76bf513a33c1dab4 (diff) | |
| download | mdnsd-083be33749b17468993fbc40e0646c1b0690e837.tar.gz | |
cache: improve service refresh behavior
- query services on all interfaces (in case they moved)
- query both PTR and A/AAAA records
Signed-off-by: Felix Fietkau <nbd@nbd.name>
| -rw-r--r-- | cache.c | 31 |
1 files changed, 16 insertions, 15 deletions
@@ -76,6 +76,18 @@ cache_is_expired(time_t t, uint32_t ttl, int frac) } static void +cache_refresh_service(struct cache_service *s) +{ + dns_query(s->entry, TYPE_PTR); + + if (!s->host) + return; + + dns_query(s->host, TYPE_A); + dns_query(s->host, TYPE_AAAA); +} + +static void cache_gc_timer(struct uloop_timeout *timeout) { struct cache_record *r, *p; @@ -108,7 +120,7 @@ cache_gc_timer(struct uloop_timeout *timeout) continue; } s->refresh += 50; - dns_send_question(s->iface, NULL, s->entry, TYPE_PTR, 0); + cache_refresh_service(s); } uloop_timeout_set(timeout, 10000); @@ -146,14 +158,8 @@ cache_update(void) dns_query(C_DNS_SD, TYPE_ANY); dns_query(C_DNS_SD, TYPE_PTR); - avl_for_each_element(&services, s, avl) { - if (s->host) { - dns_query(s->host, TYPE_A); - dns_query(s->host, TYPE_AAAA); - } else { - dns_query(s->entry, TYPE_PTR); - } - } + avl_for_each_element(&services, s, avl) + cache_refresh_service(s); } static struct cache_service* @@ -194,12 +200,7 @@ cache_service(struct interface *iface, char *entry, int hlen, int ttl) s->avl.key = type; avl_insert(&services, &s->avl); - if (hlen) { - dns_query(s->host, TYPE_A); - dns_query(s->host, TYPE_AAAA); - } else { - dns_query(entry, TYPE_PTR); - } + cache_refresh_service(s); return s; } |