diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/dbus-manager.c | 5 | ||||
-rw-r--r-- | src/core/dbus.c | 36 | ||||
-rw-r--r-- | src/core/dbus.h | 1 | ||||
-rw-r--r-- | src/core/main.c | 7 | ||||
-rw-r--r-- | src/core/manager.c | 15 | ||||
-rw-r--r-- | src/core/manager.h | 2 |
6 files changed, 56 insertions, 10 deletions
diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c index 742f6bbd85..d7604b1ab9 100644 --- a/src/core/dbus-manager.c +++ b/src/core/dbus-manager.c @@ -276,7 +276,10 @@ " <arg name=\"userspace\" type=\"t\"/>\n" \ " <arg name=\"total\" type=\"t\"/>\n" \ " </signal>" \ - " <signal name=\"UnitFilesChanged\"/>\n" + " <signal name=\"UnitFilesChanged\"/>\n" \ + " <signal name=\"Reloading\">\n" \ + " <arg name=\"active\" type=\"b\"/>\n" \ + " </signal>" #define BUS_MANAGER_INTERFACE_PROPERTIES_GENERAL \ " <property name=\"Version\" type=\"s\" access=\"read\"/>\n" \ diff --git a/src/core/dbus.c b/src/core/dbus.c index c1bf25c69b..aa3d93bf06 100644 --- a/src/core/dbus.c +++ b/src/core/dbus.c @@ -1451,7 +1451,7 @@ void bus_broadcast_finished( usec_t userspace_usec, usec_t total_usec) { - DBusMessage *message; + _cleanup_dbus_message_unref_ DBusMessage *message = NULL; assert(m); @@ -1471,18 +1471,42 @@ void bus_broadcast_finished( DBUS_TYPE_UINT64, &total_usec, DBUS_TYPE_INVALID)) { log_oom(); - goto finish; + return; } if (bus_broadcast(m, message) < 0) { log_oom(); - goto finish; + return; } +} -finish: - if (message) - dbus_message_unref(message); +void bus_broadcast_reloading(Manager *m, bool active) { + + _cleanup_dbus_message_unref_ DBusMessage *message = NULL; + dbus_bool_t b = active; + + assert(m); + + message = dbus_message_new_signal("/org/freedesktop/systemd1", "org.freedesktop.systemd1.Manager", "Reloading"); + if (!message) { + log_oom(); + return; + } + + assert_cc(sizeof(usec_t) == sizeof(uint64_t)); + if (!dbus_message_append_args(message, + DBUS_TYPE_BOOLEAN, &b, + DBUS_TYPE_INVALID)) { + log_oom(); + return; + } + + + if (bus_broadcast(m, message) < 0) { + log_oom(); + return; + } } Set *bus_acquire_subscribed(Manager *m, DBusConnection *c) { diff --git a/src/core/dbus.h b/src/core/dbus.h index b5c28c6ab6..6500cd7455 100644 --- a/src/core/dbus.h +++ b/src/core/dbus.h @@ -43,6 +43,7 @@ bool bus_connection_has_subscriber(Manager *m, DBusConnection *c); int bus_fdset_add_all(Manager *m, FDSet *fds); void bus_broadcast_finished(Manager *m, usec_t firmware_usec, usec_t loader_usec, usec_t kernel_usec, usec_t initrd_usec, usec_t userspace_usec, usec_t total_usec); +void bus_broadcast_reloading(Manager *m, bool active); Set *bus_acquire_subscribed(Manager *m, DBusConnection *c); diff --git a/src/core/main.c b/src/core/main.c index 1d188e0bfe..efc5791bbc 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -1055,15 +1055,16 @@ static int prepare_reexecute(Manager *m, FILE **_f, FDSet **_fds, bool switching assert(_f); assert(_fds); - /* Make sure nothing is really destructed when we shut down */ - m->n_reloading ++; - r = manager_open_serialization(m, &f); if (r < 0) { log_error("Failed to create serialization file: %s", strerror(-r)); goto fail; } + /* Make sure nothing is really destructed when we shut down */ + m->n_reloading ++; + bus_broadcast_reloading(m, true); + fds = fdset_new(); if (!fds) { r = -ENOMEM; diff --git a/src/core/manager.c b/src/core/manager.c index 51f03de098..2e98181b37 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -864,6 +864,11 @@ int manager_startup(Manager *m, FILE *serialization, FDSet *fds) { if (serialization) { assert(m->n_reloading > 0); m->n_reloading --; + + /* Let's wait for the UnitNew/JobNew messages being + * sent, before we notify that the reload is + * finished */ + m->send_reloading_done = true; } return r; @@ -1163,6 +1168,13 @@ unsigned manager_dispatch_dbus_queue(Manager *m) { } m->dispatching_dbus_queue = false; + + if (m->send_reloading_done) { + m->send_reloading_done = false; + + bus_broadcast_reloading(m, false); + } + return n; } @@ -2238,6 +2250,7 @@ int manager_reload(Manager *m) { return r; m->n_reloading ++; + bus_broadcast_reloading(m, true); fds = fdset_new(); if (!fds) { @@ -2297,6 +2310,8 @@ int manager_reload(Manager *m) { assert(m->n_reloading > 0); m->n_reloading--; + m->send_reloading_done = true; + finish: if (f) fclose(f); diff --git a/src/core/manager.h b/src/core/manager.h index 31da04e47c..6d5241497d 100644 --- a/src/core/manager.h +++ b/src/core/manager.h @@ -195,6 +195,8 @@ struct Manager { int32_t conn_data_slot; int32_t subscribed_data_slot; + bool send_reloading_done; + uint32_t current_job_id; uint32_t default_unit_job_id; |