]> git.ipfire.org Git - thirdparty/systemd.git/commit - src/core/service.c
core: fix bus name synchronization after daemon-reload 2202/head
authorDaniel Mack <daniel@zonque.org>
Fri, 18 Dec 2015 16:28:15 +0000 (17:28 +0100)
committerDaniel Mack <daniel@zonque.org>
Mon, 21 Dec 2015 10:23:08 +0000 (11:23 +0100)
commitd8ccf5fdc91c46ab5d0ae86e38c206bc508d4188
tree0bb0e99da1d9eb38b5b32d6c05c672d60cd992cd
parent47260caf023c93840b9dbc58305bcc2e2992f79b
core: fix bus name synchronization after daemon-reload

During daemon-reload, PID1 temporarly loses its DBus connection, so there's
a small window in which all signals sent by dbus-daemon are lost.

This is a problem, since we rely on the NameOwnerChanged signals in order to
consider a service with Type=dbus fully started or terminated, respectively.

In order to fix this, a rewrite of bus_list_names() is necessary. We used
to walk the current list of names on the bus, and blindly triggered the
bus_name_owner_change() callback on each service, providing the actual name
as current owner. This implementation has a number of problems:

* We cannot detect if the the name was moved from one owner to the other
  while we were reloading

* We don't notify services which missed the name loss signal

* Providing the actual name as current owner is a hack, as the comment also
  admits.

To fix this, this patch carries the following changes:

* Track the name of the current bus name owner, and (de-)serialize it
  during reload. This way, we can detect changes.

* In bus_list_names(), walk the list of bus names we're interested in
  first, and then see if the name is active on the bus. If it is,
  check it it's still the same as it used to be, and synthesize
  NameOwnerChanged signals for the name add and/or loss.

This should fully synchronize the current name list with the internal
state of all services.
src/core/dbus.c
src/core/service.c
src/core/service.h