mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-08-27 21:50:15 +03:00
core: in bus_init_system() make sure we setup the system bus even if we inherit the API bus
This corrects the control flow: when we reuse the API bus as system bus, let's definitely invoke bus_init_system() too, so that it is called regardless how we acquired the bus object. (Note that this doesn't actually change anything, as we only inherit the bus like this in system mode, and bus_init_system() doesn't do anything in system bus, besides writing a log message)
This commit is contained in:
@ -958,23 +958,22 @@ int bus_init_system(Manager *m) {
|
||||
return 0;
|
||||
|
||||
/* The API and system bus is the same if we are running in system mode */
|
||||
if (MANAGER_IS_SYSTEM(m) && m->api_bus) {
|
||||
m->system_bus = sd_bus_ref(m->api_bus);
|
||||
return 0;
|
||||
if (MANAGER_IS_SYSTEM(m) && m->api_bus)
|
||||
bus = sd_bus_ref(m->api_bus);
|
||||
else {
|
||||
r = sd_bus_open_system(&bus);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to connect to system bus: %m");
|
||||
|
||||
r = sd_bus_attach_event(bus, m->event, SD_EVENT_PRIORITY_NORMAL);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to attach system bus to event loop: %m");
|
||||
|
||||
r = bus_setup_disconnected_match(m, bus);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
r = sd_bus_open_system(&bus);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to connect to system bus: %m");
|
||||
|
||||
r = bus_setup_disconnected_match(m, bus);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = sd_bus_attach_event(bus, m->event, SD_EVENT_PRIORITY_NORMAL);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to attach system bus to event loop: %m");
|
||||
|
||||
r = bus_setup_system(m, bus);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to set up system bus: %m");
|
||||
|
Reference in New Issue
Block a user