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).
This commit is contained in:
Lennart Poettering
2014-05-15 01:15:30 +02:00
parent 9a78148e40
commit 19befb2d5f
34 changed files with 868 additions and 652 deletions
+3 -5
View File
@@ -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;
}