Commit 5e8d1c9a authored by Lennart Poettering's avatar Lennart Poettering

dbus: to make sure that systemd stays controllable during early bootup,...

dbus: to make sure that systemd stays controllable during early bootup, register our services on our own micro usb server in addition to the bus
parent f9704703
......@@ -59,12 +59,12 @@
* systemd-sysvinit as package
* abstract namespace dbus socket
* patch /etc/init.d/functions with:
if [ $PPID -ne 1 && mountpoint /cgroup/systemd ] ; then echo "You suck!" ; fi
* remove MANAGER_SYSTEM
Regularly:
* look for close() vs. close_nointr() vs. close_nointr_nofail()
......
......@@ -38,12 +38,12 @@
const char bus_automount_interface[] = BUS_AUTOMOUNT_INTERFACE;
DBusHandlerResult bus_automount_message_handler(Unit *u, DBusMessage *message) {
DBusHandlerResult bus_automount_message_handler(Unit *u, DBusConnection *c, DBusMessage *message) {
const BusProperty properties[] = {
BUS_UNIT_PROPERTIES,
{ "org.freedesktop.systemd1.Automount", "Where", bus_property_append_string, "s", u->automount.where },
{ NULL, NULL, NULL, NULL, NULL }
};
return bus_default_message_handler(u->meta.manager, message, INTROSPECTION, properties);
return bus_default_message_handler(u->meta.manager, c, message, INTROSPECTION, properties);
}
......@@ -26,7 +26,7 @@
#include "unit.h"
DBusHandlerResult bus_automount_message_handler(Unit *u, DBusMessage *message);
DBusHandlerResult bus_automount_message_handler(Unit *u, DBusConnection *c, DBusMessage *message);
extern const char bus_automount_interface[];
......
......@@ -38,12 +38,12 @@
const char bus_device_interface[] = BUS_DEVICE_INTERFACE;
DBusHandlerResult bus_device_message_handler(Unit *u, DBusMessage *message) {
DBusHandlerResult bus_device_message_handler(Unit *u, DBusConnection *c, DBusMessage *message) {
const BusProperty properties[] = {
BUS_UNIT_PROPERTIES,
{ "org.freedesktop.systemd1.Device", "SysFSPath", bus_property_append_string, "s", u->device.sysfs },
{ NULL, NULL, NULL, NULL, NULL }
};
return bus_default_message_handler(u->meta.manager, message, INTROSPECTION, properties);
return bus_default_message_handler(u->meta.manager, c, message, INTROSPECTION, properties);
}
......@@ -26,7 +26,7 @@
#include "unit.h"
DBusHandlerResult bus_device_message_handler(Unit *u, DBusMessage *message);
DBusHandlerResult bus_device_message_handler(Unit *u, DBusConnection *c, DBusMessage *message);
extern const char bus_device_interface[];
......
......@@ -78,7 +78,7 @@ static int bus_job_append_unit(Manager *m, DBusMessageIter *i, const char *prope
return 0;
}
static DBusHandlerResult bus_job_message_dispatch(Job *j, DBusMessage *message) {
static DBusHandlerResult bus_job_message_dispatch(Job *j, DBusConnection *connection, DBusMessage *message) {
const BusProperty properties[] = {
{ "org.freedesktop.systemd1.Job", "Id", bus_property_append_uint32, "u", &j->id },
{ "org.freedesktop.systemd1.Job", "State", bus_job_append_state, "s", &j->state },
......@@ -88,7 +88,6 @@ static DBusHandlerResult bus_job_message_dispatch(Job *j, DBusMessage *message)
};
DBusMessage *reply = NULL;
Manager *m = j->manager;
if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Job", "Cancel")) {
if (!(reply = dbus_message_new_method_return(message)))
......@@ -97,10 +96,10 @@ static DBusHandlerResult bus_job_message_dispatch(Job *j, DBusMessage *message)
job_free(j);
} else
return bus_default_message_handler(j->manager, message, INTROSPECTION, properties);
return bus_default_message_handler(j->manager, connection, message, INTROSPECTION, properties);
if (reply) {
if (!dbus_connection_send(m->api_bus, reply, NULL))
if (!dbus_connection_send(connection, reply, NULL))
goto oom;
dbus_message_unref(reply);
......@@ -115,7 +114,7 @@ oom:
return DBUS_HANDLER_RESULT_NEED_MEMORY;
}
static DBusHandlerResult bus_job_message_handler(DBusConnection *connection, DBusMessage *message, void *data) {
static DBusHandlerResult bus_job_message_handler(DBusConnection *connection, DBusMessage *message, void *data) {
Manager *m = data;
Job *j;
int r;
......@@ -137,10 +136,10 @@ static DBusHandlerResult bus_job_message_handler(DBusConnection *connection, DB
if (r == -ENOENT)
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
return bus_send_error_reply(m, message, NULL, r);
return bus_send_error_reply(m, connection, message, NULL, r);
}
return bus_job_message_dispatch(j, message);
return bus_job_message_dispatch(j, connection, message);
}
const DBusObjectPathVTable bus_job_vtable = {
......@@ -183,7 +182,7 @@ void bus_job_send_change_signal(Job *j) {
goto oom;
}
if (!dbus_connection_send(j->manager->api_bus, m, NULL))
if (bus_broadcast(j->manager, m) < 0)
goto oom;
free(p);
......@@ -228,7 +227,7 @@ void bus_job_send_removed_signal(Job *j, bool success) {
DBUS_TYPE_INVALID))
goto oom;
if (!dbus_connection_send(j->manager->api_bus, m, NULL))
if (bus_broadcast(j->manager, m) < 0)
goto oom;
free(p);
......
......@@ -185,7 +185,7 @@ static int bus_manager_append_n_jobs(Manager *m, DBusMessageIter *i, const char
return 0;
}
static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection, DBusMessage *message, void *data) {
static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection, DBusMessage *message, void *data) {
Manager *m = data;
const BusProperty properties[] = {
......@@ -226,10 +226,10 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection
&error,
DBUS_TYPE_STRING, &name,
DBUS_TYPE_INVALID))
return bus_send_error_reply(m, message, &error, -EINVAL);
return bus_send_error_reply(m, connection, message, &error, -EINVAL);
if (!(u = manager_get_unit(m, name)))
return bus_send_error_reply(m, message, NULL, -ENOENT);
return bus_send_error_reply(m, connection, message, NULL, -ENOENT);
if (!(reply = dbus_message_new_method_return(message)))
goto oom;
......@@ -252,10 +252,10 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection
&error,
DBUS_TYPE_STRING, &name,
DBUS_TYPE_INVALID))
return bus_send_error_reply(m, message, &error, -EINVAL);
return bus_send_error_reply(m, connection, message, &error, -EINVAL);
if ((r = manager_load_unit(m, name, NULL, &u)) < 0)
return bus_send_error_reply(m, message, NULL, r);
return bus_send_error_reply(m, connection, message, NULL, r);
if (!(reply = dbus_message_new_method_return(message)))
goto oom;
......@@ -286,10 +286,10 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection
&error,
DBUS_TYPE_UINT32, &id,
DBUS_TYPE_INVALID))
return bus_send_error_reply(m, message, &error, -EINVAL);
return bus_send_error_reply(m, connection, message, &error, -EINVAL);
if (!(j = manager_get_job(m, id)))
return bus_send_error_reply(m, message, NULL, -ENOENT);
return bus_send_error_reply(m, connection, message, NULL, -ENOENT);
if (!(reply = dbus_message_new_method_return(message)))
goto oom;
......@@ -449,7 +449,7 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection
r = set_put(m->subscribed, client);
if (r < 0)
return bus_send_error_reply(m, message, NULL, r);
return bus_send_error_reply(m, connection, message, NULL, r);
if (!(reply = dbus_message_new_method_return(message)))
goto oom;
......@@ -458,7 +458,7 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection
char *client;
if (!(client = set_remove(m->subscribed, (char*) dbus_message_get_sender(message))))
return bus_send_error_reply(m, message, NULL, -ENOENT);
return bus_send_error_reply(m, connection, message, NULL, -ENOENT);
free(client);
......@@ -504,13 +504,13 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection
DBUS_TYPE_STRING, &name,
DBUS_TYPE_BOOLEAN, &cleanup,
DBUS_TYPE_INVALID))
return bus_send_error_reply(m, message, &error, -EINVAL);
return bus_send_error_reply(m, connection, message, &error, -EINVAL);
if (name && name[0] == 0)
name = NULL;
if ((r = snapshot_create(m, name, cleanup, &s)) < 0)
return bus_send_error_reply(m, message, NULL, r);
return bus_send_error_reply(m, connection, message, NULL, r);
if (!(reply = dbus_message_new_method_return(message)))
goto oom;
......@@ -609,7 +609,7 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection
} else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Manager", "Exit")) {
if (m->running_as == MANAGER_INIT)
return bus_send_error_reply(m, message, NULL, -ENOTSUP);
return bus_send_error_reply(m, connection, message, NULL, -ENOTSUP);
if (!(reply = dbus_message_new_method_return(message)))
goto oom;
......@@ -623,7 +623,7 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection
if (r == -ENOMEM)
goto oom;
return bus_send_error_reply(m, message, NULL, r);
return bus_send_error_reply(m, connection, message, NULL, r);
}
e = strv_env_merge(2, m->environment, l);
......@@ -647,7 +647,7 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection
if (r == -ENOMEM)
goto oom;
return bus_send_error_reply(m, message, NULL, r);
return bus_send_error_reply(m, connection, message, NULL, r);
}
e = strv_env_delete(m->environment, 1, l);
......@@ -663,7 +663,7 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection
m->environment = e;
} else
return bus_default_message_handler(m, message, NULL, properties);
return bus_default_message_handler(m, connection, message, NULL, properties);
if (job_type != _JOB_TYPE_INVALID) {
......@@ -678,19 +678,19 @@ static DBusHandlerResult bus_manager_message_handler(DBusConnection *connection
DBUS_TYPE_STRING, &name,
DBUS_TYPE_STRING, &smode,
DBUS_TYPE_INVALID))
return bus_send_error_reply(m, message, &error, -EINVAL);
return bus_send_error_reply(m, connection, message, &error, -EINVAL);
if ((mode = job_mode_from_string(smode)) == _JOB_MODE_INVALID)
return bus_send_error_reply(m, message, NULL, -EINVAL);
return bus_send_error_reply(m, connection, message, NULL, -EINVAL);
if ((r = manager_load_unit(m, name, NULL, &u)) < 0)
return bus_send_error_reply(m, message, NULL, r);
return bus_send_error_reply(m, connection, message, NULL, r);
if (job_type == JOB_START && u->meta.only_by_dependency)
return bus_send_error_reply(m, message, NULL, -EPERM);
return bus_send_error_reply(m, connection, message, NULL, -EPERM);
if ((r = manager_add_job(m, job_type, u, mode, true, &j)) < 0)
return bus_send_error_reply(m, message, NULL, r);
return bus_send_error_reply(m, connection, message, NULL, r);
if (!(reply = dbus_message_new_method_return(message)))
goto oom;
......
......@@ -120,7 +120,7 @@ static int bus_mount_append_type(Manager *n, DBusMessageIter *i, const char *pro
return 0;
}
DBusHandlerResult bus_mount_message_handler(Unit *u, DBusMessage *message) {
DBusHandlerResult bus_mount_message_handler(Unit *u, DBusConnection *c, DBusMessage *message) {
const BusProperty properties[] = {
BUS_UNIT_PROPERTIES,
{ "org.freedesktop.systemd1.Mount", "Where", bus_property_append_string, "s", u->mount.where },
......@@ -135,5 +135,5 @@ DBusHandlerResult bus_mount_message_handler(Unit *u, DBusMessage *message) {
{ NULL, NULL, NULL, NULL, NULL }
};
return bus_default_message_handler(u->meta.manager, message, INTROSPECTION, properties);
return bus_default_message_handler(u->meta.manager, c, message, INTROSPECTION, properties);
}
......@@ -26,7 +26,7 @@
#include "unit.h"
DBusHandlerResult bus_mount_message_handler(Unit *u, DBusMessage *message);
DBusHandlerResult bus_mount_message_handler(Unit *u, DBusConnection *c, DBusMessage *message);
extern const char bus_mount_interface[];
......
......@@ -41,12 +41,12 @@
const char bus_path_interface[] = BUS_PATH_INTERFACE;
DBusHandlerResult bus_path_message_handler(Unit *u, DBusMessage *message) {
DBusHandlerResult bus_path_message_handler(Unit *u, DBusConnection *c, DBusMessage *message) {
const BusProperty properties[] = {
BUS_UNIT_PROPERTIES,
{ "org.freedesktop.systemd1.Path", "Unit", bus_property_append_string, "s", &u->path.unit->meta.id },
{ NULL, NULL, NULL, NULL, NULL }
};
return bus_default_message_handler(u->meta.manager, message, INTROSPECTION, properties);
return bus_default_message_handler(u->meta.manager, c, message, INTROSPECTION, properties);
}
......@@ -26,7 +26,7 @@
#include "unit.h"
DBusHandlerResult bus_path_message_handler(Unit *u, DBusMessage *message);
DBusHandlerResult bus_path_message_handler(Unit *u, DBusConnection *c, DBusMessage *message);
extern const char bus_path_interface[];
......
......@@ -58,7 +58,7 @@ const char bus_service_interface[] = BUS_SERVICE_INTERFACE;
static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_service_append_type, service_type, ServiceType);
static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_service_append_restart, service_restart, ServiceRestart);
DBusHandlerResult bus_service_message_handler(Unit *u, DBusMessage *message) {
DBusHandlerResult bus_service_message_handler(Unit *u, DBusConnection *connection, DBusMessage *message) {
const BusProperty properties[] = {
BUS_UNIT_PROPERTIES,
{ "org.freedesktop.systemd1.Service", "Type", bus_service_append_type, "s", &u->service.type },
......@@ -81,5 +81,5 @@ DBusHandlerResult bus_service_message_handler(Unit *u, DBusMessage *message) {
{ NULL, NULL, NULL, NULL, NULL }
};
return bus_default_message_handler(u->meta.manager, message, INTROSPECTION, properties);
return bus_default_message_handler(u->meta.manager, connection, message, INTROSPECTION, properties);
}
......@@ -26,7 +26,7 @@
#include "unit.h"
DBusHandlerResult bus_service_message_handler(Unit *u, DBusMessage *message);
DBusHandlerResult bus_service_message_handler(Unit *u, DBusConnection *c, DBusMessage *message);
extern const char bus_service_interface[];
......
......@@ -39,7 +39,7 @@
const char bus_snapshot_interface[] = BUS_SNAPSHOT_INTERFACE;
DBusHandlerResult bus_snapshot_message_handler(Unit *u, DBusMessage *message) {
DBusHandlerResult bus_snapshot_message_handler(Unit *u, DBusConnection *c, DBusMessage *message) {
const BusProperty properties[] = {
BUS_UNIT_PROPERTIES,
{ "org.freedesktop.systemd1.Snapshot", "Cleanup", bus_property_append_bool, "b", &u->snapshot.cleanup },
......@@ -59,10 +59,10 @@ DBusHandlerResult bus_snapshot_message_handler(Unit *u, DBusMessage *message) {
goto oom;
} else
return bus_default_message_handler(u->meta.manager, message, INTROSPECTION, properties);
return bus_default_message_handler(u->meta.manager, c, message, INTROSPECTION, properties);
if (reply) {
if (!dbus_connection_send(u->meta.manager->api_bus, reply, NULL))
if (!dbus_connection_send(c, reply, NULL))
goto oom;
dbus_message_unref(reply);
......
......@@ -26,7 +26,7 @@
#include "unit.h"
DBusHandlerResult bus_snapshot_message_handler(Unit *u, DBusMessage *message);
DBusHandlerResult bus_snapshot_message_handler(Unit *u, DBusConnection *c, DBusMessage *message);
extern const char bus_snapshot_interface[];
......
......@@ -52,7 +52,7 @@ const char bus_socket_interface[] = BUS_SOCKET_INTERFACE;
static DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_socket_append_bind_ipv6_only, socket_address_bind_ipv6_only, SocketAddressBindIPv6Only);
DBusHandlerResult bus_socket_message_handler(Unit *u, DBusMessage *message) {
DBusHandlerResult bus_socket_message_handler(Unit *u, DBusConnection *c, DBusMessage *message) {
const BusProperty properties[] = {
BUS_UNIT_PROPERTIES,
{ "org.freedesktop.systemd1.Socket", "BindIPv6Only", bus_socket_append_bind_ipv6_only, "s", &u->socket.bind_ipv6_only },
......@@ -69,5 +69,5 @@ DBusHandlerResult bus_socket_message_handler(Unit *u, DBusMessage *message) {
{ NULL, NULL, NULL, NULL, NULL }
};
return bus_default_message_handler(u->meta.manager, message, INTROSPECTION, properties);
return bus_default_message_handler(u->meta.manager, c, message, INTROSPECTION, properties);
}
......@@ -26,7 +26,7 @@
#include "unit.h"
DBusHandlerResult bus_socket_message_handler(Unit *u, DBusMessage *message);
DBusHandlerResult bus_socket_message_handler(Unit *u, DBusConnection *c, DBusMessage *message);
extern const char bus_socket_interface[];
......
......@@ -66,7 +66,7 @@ static int bus_swap_append_priority(Manager *m, DBusMessageIter *i, const char *
return 0;
}
DBusHandlerResult bus_swap_message_handler(Unit *u, DBusMessage *message) {
DBusHandlerResult bus_swap_message_handler(Unit *u, DBusConnection *c, DBusMessage *message) {
const BusProperty properties[] = {
BUS_UNIT_PROPERTIES,
{ "org.freedesktop.systemd1.Swap", "What", bus_property_append_string, "s", u->swap.what },
......@@ -74,5 +74,5 @@ DBusHandlerResult bus_swap_message_handler(Unit *u, DBusMessage *message) {
{ NULL, NULL, NULL, NULL, NULL }
};
return bus_default_message_handler(u->meta.manager, message, INTROSPECTION, properties);
return bus_default_message_handler(u->meta.manager, c, message, INTROSPECTION, properties);
}
......@@ -27,7 +27,7 @@
#include "unit.h"
DBusHandlerResult bus_swap_message_handler(Unit *u, DBusMessage *message);
DBusHandlerResult bus_swap_message_handler(Unit *u, DBusConnection *c, DBusMessage *message);
extern const char bus_swap_interface[];
......
......@@ -37,11 +37,11 @@
const char bus_target_interface[] = BUS_TARGET_INTERFACE;
DBusHandlerResult bus_target_message_handler(Unit *u, DBusMessage *message) {
DBusHandlerResult bus_target_message_handler(Unit *u, DBusConnection *c, DBusMessage *message) {
const BusProperty properties[] = {
BUS_UNIT_PROPERTIES,
{ NULL, NULL, NULL, NULL, NULL }
};
return bus_default_message_handler(u->meta.manager, message, INTROSPECTION, properties);
return bus_default_message_handler(u->meta.manager, c, message, INTROSPECTION, properties);
}
......@@ -26,7 +26,7 @@
#include "unit.h"
DBusHandlerResult bus_target_message_handler(Unit *u, DBusMessage *message);
DBusHandlerResult bus_target_message_handler(Unit *u, DBusConnection *c, DBusMessage *message);
extern const char bus_target_interface[];
......
......@@ -41,12 +41,12 @@
const char bus_timer_interface[] = BUS_TIMER_INTERFACE;
DBusHandlerResult bus_timer_message_handler(Unit *u, DBusMessage *message) {
DBusHandlerResult bus_timer_message_handler(Unit *u, DBusConnection *c, DBusMessage *message) {
const BusProperty properties[] = {
BUS_UNIT_PROPERTIES,
{ "org.freedesktop.systemd1.Timer", "Unit", bus_property_append_string, "s", &u->timer.unit->meta.id },
{ NULL, NULL, NULL, NULL, NULL }
};
return bus_default_message_handler(u->meta.manager, message, INTROSPECTION, properties);
return bus_default_message_handler(u->meta.manager, c, message, INTROSPECTION, properties);
}
......@@ -26,7 +26,7 @@
#include "unit.h"
DBusHandlerResult bus_timer_message_handler(Unit *u, DBusMessage *message);
DBusHandlerResult bus_timer_message_handler(Unit *u, DBusConnection *c, DBusMessage *message);
extern const char bus_timer_interface[];
......
......@@ -255,7 +255,7 @@ int bus_unit_append_cgroups(Manager *m, DBusMessageIter *i, const char *property
DEFINE_BUS_PROPERTY_APPEND_ENUM(bus_unit_append_kill_mode, kill_mode, KillMode);
static DBusHandlerResult bus_unit_message_dispatch(Unit *u, DBusMessage *message) {
static DBusHandlerResult bus_unit_message_dispatch(Unit *u, DBusConnection *connection, DBusMessage *message) {
DBusMessage *reply = NULL;
Manager *m = u->meta.manager;
DBusError error;
......@@ -273,7 +273,7 @@ static DBusHandlerResult bus_unit_message_dispatch(Unit *u, DBusMessage *message
else if (dbus_message_is_method_call(message, "org.freedesktop.systemd1.Unit", "Restart"))
job_type = JOB_RESTART;
else if (UNIT_VTABLE(u)->bus_message_handler)
return UNIT_VTABLE(u)->bus_message_handler(u, message);
return UNIT_VTABLE(u)->bus_message_handler(u, connection, message);
else
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
......@@ -284,20 +284,20 @@ static DBusHandlerResult bus_unit_message_dispatch(Unit *u, DBusMessage *message
int r;
if (job_type == JOB_START && u->meta.only_by_dependency)
return bus_send_error_reply(m, message, NULL, -EPERM);
return bus_send_error_reply(m, connection, message, NULL, -EPERM);
if (!dbus_message_get_args(
message,
&error,
DBUS_TYPE_STRING, &smode,
DBUS_TYPE_INVALID))
return bus_send_error_reply(m, message, &error, -EINVAL);
return bus_send_error_reply(m, connection, message, &error, -EINVAL);
if ((mode = job_mode_from_string(smode)) == _JOB_MODE_INVALID)
return bus_send_error_reply(m, message, NULL, -EINVAL);
return bus_send_error_reply(m, connection, message, NULL, -EINVAL);
if ((r = manager_add_job(m, job_type, u, mode, true, &j)) < 0)
return bus_send_error_reply(m, message, NULL, r);
return bus_send_error_reply(m, connection, message, NULL, r);
if (!(reply = dbus_message_new_method_return(message)))
goto oom;
......@@ -315,7 +315,7 @@ static DBusHandlerResult bus_unit_message_dispatch(Unit *u, DBusMessage *message
free(path);
if (reply) {
if (!dbus_connection_send(m->api_bus, reply, NULL))
if (!dbus_connection_send(connection, reply, NULL))
goto oom;
dbus_message_unref(reply);
......@@ -334,7 +334,7 @@ oom:
return DBUS_HANDLER_RESULT_NEED_MEMORY;
}
static DBusHandlerResult bus_unit_message_handler(DBusConnection *connection, DBusMessage *message, void *data) {
static DBusHandlerResult bus_unit_message_handler(DBusConnection *connection, DBusMessage *message, void *data) {
Manager *m = data;
Unit *u;
int r;
......@@ -356,10 +356,10 @@ static DBusHandlerResult bus_unit_message_handler(DBusConnection *connection, D
if (r == -ENOENT)
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
return bus_send_error_reply(m, message, NULL, r);
return bus_send_error_reply(m, connection, message, NULL, r);
}
return bus_unit_message_dispatch(u, message);
return bus_unit_message_dispatch(u, connection, message);
}
const DBusObjectPathVTable bus_unit_vtable = {
......@@ -402,7 +402,7 @@ void bus_unit_send_change_signal(Unit *u) {
goto oom;
}
if (!dbus_connection_send(u->meta.manager->api_bus, m, NULL))
if (bus_broadcast(u->meta.manager, m) < 0)
goto oom;
free(p);
......@@ -445,7 +445,7 @@ void bus_unit_send_removed_signal(Unit *u) {
DBUS_TYPE_INVALID))
goto oom;
if (!dbus_connection_send(u->meta.manager->api_bus, m, NULL))
if (bus_broadcast(u->meta.manager, m) < 0)
goto oom;
free(p);
......
This diff is collapsed.
......@@ -56,10 +56,8 @@ typedef struct BusProperty {
" </method>\n" \
" </interface>\n"
int bus_init_system(Manager *m);
int bus_init_api(Manager *m);
void bus_done_system(Manager *m);
void bus_done_api(Manager *m);
int bus_init(Manager *m);
void bus_done(Manager *m);
unsigned bus_dispatch(Manager *m);
......@@ -68,9 +66,10 @@ void bus_timeout_event(Manager *m, Watch *w, int events);
int bus_query_pid(Manager *m, const char *name);
DBusHandlerResult bus_default_message_handler(Manager *m, DBusMessage *message, const char* introspection, const BusProperty *properties);
DBusHandlerResult bus_default_message_handler(Manager *m, DBusConnection *c, DBusMessage *message, const char* introspection, const BusProperty *properties);
DBusHandlerResult bus_send_error_reply(Manager *m, DBusConnection *c, DBusMessage *message, DBusError *bus_error, int error);
DBusHandlerResult bus_send_error_reply(Manager *m, DBusMessage *message, DBusError *bus_error, int error);
int bus_broadcast(Manager *m, DBusMessage *message);
int bus_property_append_string(Manager *m, DBusMessageIter *i, const char *property, void *data);
int bus_property_append_strv(Manager *m, DBusMessageIter *i, const char *property, void *data);
......
......@@ -243,8 +243,7 @@ int manager_new(ManagerRunningAs running_as, bool confirm_spawn, Manager **_m) {
goto fail;
/* Try to connect to the busses, if possible. */
if ((r = bus_init_system(m)) < 0 ||
(r = bus_init_api(m)) < 0)
if ((r = bus_init(m)) < 0)
goto fail;
if (asprintf(&p, "%s/%s", m->cgroup_mount_point, m->cgroup_hierarchy) < 0) {
......@@ -424,8 +423,7 @@ void manager_free(Manager *m) {
* around */
manager_shutdown_cgroup(m, m->exit_code != MANAGER_REEXECUTE);
bus_done_api(m);
bus_done_system(m);
bus_done(m);
hashmap_free(m->units);
hashmap_free(m->jobs);
......@@ -1826,8 +1824,7 @@ static int manager_process_signal_fd(Manager *m) {
if (!u || UNIT_IS_ACTIVE_OR_RELOADING(unit_active_state(u))) {
log_info("Trying to reconnect to bus...");
bus_init_system(m);
bus_init_api(m);
bus_init(m);
}
if (!u || !UNIT_IS_ACTIVE_OR_ACTIVATING(unit_active_state(u))) {
......
......@@ -154,6 +154,9 @@ struct Manager {
/* Data specific to the D-Bus subsystem */
DBusConnection *api_bus, *system_bus;
DBusServer *private_bus;
Set *bus_connections, *bus_connections_for_dispatch;