From 19befb2d5fc087f96e40ddc432b2cc9385666209 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 15 May 2014 01:15:30 +0200 Subject: sd-bus: introduce sd_bus_slot objects encapsulating callbacks or vtables attached to a bus connection This makes callback behaviour more like sd-event or sd-resolve, and creates proper object for unregistering callbacks. Taking the refernce to the slot is optional. If not taken life time of the slot will be bound to the underlying bus object (or in the case of an async call until the reply has been recieved). --- src/systemctl/systemctl.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/systemctl') diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c index e1e4640ae8..91d8032945 100644 --- a/src/systemctl/systemctl.c +++ b/src/systemctl/systemctl.c @@ -2305,6 +2305,7 @@ static int enable_wait_for_jobs(sd_bus *bus) { r = sd_bus_add_match( bus, + NULL, "type='signal'," "sender='org.freedesktop.systemd1'," "interface='org.freedesktop.systemd1.Manager'," @@ -2364,13 +2365,14 @@ static int check_wait_response(WaitData *d) { } static int wait_for_jobs(sd_bus *bus, Set *s) { + _cleanup_bus_slot_unref_ sd_bus_slot *slot = NULL; WaitData d = { .set = s }; int r = 0, q; assert(bus); assert(s); - q = sd_bus_add_filter(bus, wait_filter, &d); + q = sd_bus_add_filter(bus, &slot, wait_filter, &d); if (q < 0) return log_oom(); @@ -2398,10 +2400,6 @@ static int wait_for_jobs(sd_bus *bus, Set *s) { d.result = NULL; } - q = sd_bus_remove_filter(bus, wait_filter, &d); - if (q < 0 && r == 0) - r = q; - return r; } -- cgit v1.2.3-54-g00ecf