resolved: publish browsed service after initialization

dns_add_new_service() links a _cleanup_ service into the browser
before copying its record and registering its maintenance timer has fully
succeeded. A timer setup failure then frees the service while leaving the
list head pointing at it.

Follow-up for 8458b7fb91
This commit is contained in:
Luca Boccassi
2026-07-13 14:41:42 +01:00
parent 2e1c8bc3d7
commit 82044c2fe9
+4 -2
View File
@@ -178,8 +178,8 @@ int dns_add_new_service(DnsServiceBrowser *sb, DnsResourceRecord *rr, int owner_
.query = NULL,
.rr_ttl_state = DNS_RECORD_TTL_STATE_80_PERCENT,
};
LIST_PREPEND(dns_services, sb->dns_services, s);
if (!s->rr)
return log_oom();
/* Schedule the first cache maintenance query at 80% of the record's
* TTL. Subsequent queries issued at 5% increments until 100% of the
@@ -219,6 +219,8 @@ int dns_add_new_service(DnsServiceBrowser *sb, DnsResourceRecord *rr, int owner_
r,
"Failed to schedule mDNS maintenance query for DNS service: %m");
LIST_PREPEND(dns_services, sb->dns_services, s);
TAKE_PTR(s);
return 0;
}