Skip to content

Commit

Permalink
importd: unify setup of bus connectivity in one place
Browse files Browse the repository at this point in the history
  • Loading branch information
poettering authored and bluca committed Jun 15, 2024
1 parent 609bc3a commit 3b2e99e
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/import/importd.c
Original file line number Diff line number Diff line change
Expand Up @@ -706,10 +706,6 @@ static int manager_new(Manager **ret) {
if (r < 0)
log_debug_errno(r, "Failed to enable watchdog logic, ignoring: %m");

r = sd_bus_default_system(&m->bus);
if (r < 0)
return r;

m->notify_fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0);
if (m->notify_fd < 0)
return -errno;
Expand Down Expand Up @@ -1703,10 +1699,16 @@ static const BusObjectImplementation manager_object = {
.children = BUS_IMPLEMENTATIONS(&transfer_object),
};

static int manager_add_bus_objects(Manager *m) {
static int manager_connect_bus(Manager *m) {
int r;

assert(m);
assert(m->event);
assert(!m->bus);

r = sd_bus_default_system(&m->bus);
if (r < 0)
return log_error_errno(r, "Failed to get system bus connection: %m");

r = bus_add_implementation(m->bus, &manager_object, m);
if (r < 0)
Expand Down Expand Up @@ -1780,7 +1782,7 @@ static int run(int argc, char *argv[]) {

manager_parse_env(m);

r = manager_add_bus_objects(m);
r = manager_connect_bus(m);
if (r < 0)
return r;

Expand Down

0 comments on commit 3b2e99e

Please sign in to comment.