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:
+10
-9
@@ -1059,7 +1059,6 @@ static int start_transient_service(
|
||||
.inactive_enter_usec = USEC_INFINITY,
|
||||
};
|
||||
_cleanup_free_ char *path = NULL;
|
||||
const char *mt;
|
||||
|
||||
c.bus = sd_bus_ref(bus);
|
||||
|
||||
@@ -1089,18 +1088,20 @@ static int start_transient_service(
|
||||
if (!path)
|
||||
return log_oom();
|
||||
|
||||
mt = strjoina("type='signal',"
|
||||
"sender='org.freedesktop.systemd1',"
|
||||
"path='", path, "',"
|
||||
"interface='org.freedesktop.DBus.Properties',"
|
||||
"member='PropertiesChanged'");
|
||||
r = sd_bus_add_match(bus, &c.match, mt, on_properties_changed, &c);
|
||||
r = sd_bus_match_signal_async(
|
||||
bus,
|
||||
&c.match,
|
||||
"org.freedesktop.systemd1",
|
||||
path,
|
||||
"org.freedesktop.DBus.Properties",
|
||||
"PropertiesChanged",
|
||||
on_properties_changed, NULL, &c);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to add properties changed signal.");
|
||||
return log_error_errno(r, "Failed to request properties changed signal match: %m");
|
||||
|
||||
r = sd_bus_attach_event(bus, c.event, SD_EVENT_PRIORITY_NORMAL);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to attach bus to event loop.");
|
||||
return log_error_errno(r, "Failed to attach bus to event loop: %m");
|
||||
|
||||
r = run_context_update(&c, path);
|
||||
if (r < 0)
|
||||
|
||||
Reference in New Issue
Block a user