1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-25 06:03:40 +03:00

bus: make sure exit-on-idle logic works on kdbus systems that do not generate NameLost

This commit is contained in:
Lennart Poettering 2013-12-12 21:25:47 +01:00
parent 2c8d477a01
commit 11846aa746

View File

@ -48,16 +48,29 @@ static int quit_callback(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bus_
int bus_async_unregister_and_quit(sd_event *e, sd_bus *bus, const char *name) {
_cleanup_free_ char *match = NULL;
const char *unique;
int r;
assert(e);
assert(bus);
assert(name);
r = asprintf(&match, "type='signal',sender='org.freedesktop.DBus',interface='org.freedesktop.DBus',member='NameLost',arg0='%s'", name);
r = sd_bus_get_unique_name(bus, &unique);
if (r < 0)
return r;
r = asprintf(&match,
"sender='org.freedesktop.DBus',"
"type='signal',"
"interface='org.freedesktop.DBus',"
"member='NameOwnerChanged',"
"path='/org/freedesktop/DBus',"
"arg0='%s',"
"arg1='%s',"
"arg2=''", name, unique);
if (r < 0)
return -ENOMEM;
r = sd_bus_add_match(bus, match, quit_callback, e);
if (r < 0)
return r;
@ -66,9 +79,6 @@ int bus_async_unregister_and_quit(sd_event *e, sd_bus *bus, const char *name) {
if (r < 0)
return r;
if (r != BUS_NAME_RELEASED)
return -EIO;
return 0;
}