tree-wide: install matches asynchronously

Let's remove a number of synchronization points from our service
startups: let's drop synchronous match installation, and let's opt for
asynchronous instead.

Also, let's use sd_bus_match_signal() instead of sd_bus_add_match()
where we can.
This commit is contained in:
Lennart Poettering
2018-01-05 13:58:32 +01:00
parent 0c0b930647
commit 75152a4d6a
14 changed files with 183 additions and 196 deletions
+1 -3
View File
@@ -259,9 +259,7 @@ _public_ int sd_bus_track_add_name(sd_bus_track *track, const char *name) {
bus_track_remove_from_queue(track); /* don't dispatch this while we work in it */
track->n_adding++; /* make sure we aren't dispatched while we synchronously add this match */
r = sd_bus_add_match(track->bus, &n->slot, match, on_name_owner_changed, track);
track->n_adding--;
r = sd_bus_add_match_async(track->bus, &n->slot, match, on_name_owner_changed, NULL, track);
if (r < 0) {
bus_track_add_to_queue(track);
return r;
+2 -2
View File
@@ -102,9 +102,9 @@ static int server_init(sd_bus **_bus) {
goto fail;
}
r = sd_bus_add_match(bus, NULL, "type='signal',interface='foo.bar',member='Notify'", match_callback, NULL);
r = sd_bus_match_signal(bus, NULL, NULL, NULL, "foo.bar", "Notify", match_callback, NULL);
if (r < 0) {
log_error_errno(r, "Failed to add match: %m");
log_error_errno(r, "Failed to request match: %m");
goto fail;
}