summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;
}