resolved: actually unregister DNS-SD services when the bus client vanishes
Since the D-Bus DNS-SD API was introduced in c3036641f0 ("resolved:
implement D-Bus API for DNS-SD", v236), RegisterService() has set up an
sd_bus_track object so that a registered service is destroyed when the
client that registered it disconnects from the bus — there's even a
handler logging "Client of active request vanished, destroying DNS-SD
service."
However, the track object was never stored anywhere: it is declared as
a _cleanup_(sd_bus_track_unrefp) local in bus_method_register_service()
and hence destroyed again when the method handler returns, taking the
tracking down with it. The vanish handler was thus dead code, and
services registered via D-Bus silently persisted after their client
disconnected — unowned, impossible to re-register (the identifier
stays taken, failing with DNSSD_SERVICE_EXISTS), and advertised until
systemd-resolved itself exited.
Store the track object in DnssdRegisteredService, pinning it for the
lifetime of the service, so that client tracking works as originally
intended. Route the vanish path through the full unregistration logic
(goodbye packets + removal from the per-link mDNS zones), since freeing
the service alone would leave its RRs published in the zones.
Note for fire-and-forget clients (e.g. one-shot busctl/gdbus calls):
these were never reliable — the registration silently vanished on any
resolved restart — and now behave as documented for the corresponding
Avahi API as well: the bus connection must be kept open for as long as
the service is to remain registered. Document that in the man page and
NEWS, and point to *.dnssd files for registrations independent of a
client's lifetime.
This commit is contained in:
@@ -4,6 +4,19 @@ CHANGES WITH 262:
|
||||
|
||||
Feature Removals and Incompatible Changes:
|
||||
|
||||
* DNS-SD services registered via systemd-resolved's D-Bus method
|
||||
org.freedesktop.resolve1.Manager.RegisterService() are now
|
||||
unregistered automatically when the client that registered them
|
||||
disconnects from the bus, as originally intended and matching the
|
||||
behavior of the equivalent Avahi API. Due to a bug the client
|
||||
tracking never worked, and such services used to stay registered
|
||||
until systemd-resolved exited (but did not survive a restart of the
|
||||
daemon either). Clients must now keep their bus connection open for
|
||||
as long as the service shall remain registered; one-shot
|
||||
registrations, e.g. via busctl or gdbus, will be withdrawn again as
|
||||
soon as the tool exits. To register a DNS-SD service independently
|
||||
of a client's lifetime, use *.dnssd files, see systemd.dnssd(5).
|
||||
|
||||
* Meson options '-Dlibiptc=' (deprecated in v259), '-Dlibidn=',
|
||||
'-Drc-local=', '-Dsysvinit-path=', and '-Dsysvrcnd-path=' (deprecated
|
||||
in v260) have been removed.
|
||||
|
||||
Reference in New Issue
Block a user