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:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user