summaryrefslogtreecommitdiff
path: root/src/libsystemd-bus
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-12-12 21:25:47 +0100
committerLennart Poettering <lennart@poettering.net>2013-12-13 04:06:43 +0100
commit11846aa74680bab65711427b1e7702e783b2894c (patch)
tree7aaf83650f266b7fe2ccd16bb8681bc3a49a02f6 /src/libsystemd-bus
parent2c8d477a01cd154bbaab6c46a5ffeed3e55f1a6b (diff)
bus: make sure exit-on-idle logic works on kdbus systems that do not generate NameLost
Diffstat (limited to 'src/libsystemd-bus')
-rw-r--r--src/libsystemd-bus/bus-util.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/libsystemd-bus/bus-util.c b/src/libsystemd-bus/bus-util.c
index 9a42b051aa..3afcb82bcb 100644
--- a/src/libsystemd-bus/bus-util.c
+++ b/src/libsystemd-bus/bus-util.c
@@ -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;
}