diff options
author | Ralf Habacker <ralf.habacker@freenet.de> | 2022-02-16 00:14:37 +0100 |
---|---|---|
committer | Ralf Habacker <ralf.habacker@freenet.de> | 2022-02-16 14:00:13 +0100 |
commit | 564056e21e858b2402bd5d5a2eedb15380261732 (patch) | |
tree | fc2cc7baa9fe89630d9cce7dd74e0c5fb402c140 /bus/bus.c | |
parent | 5efc97f03ca581df139b8ed4bca75b333d9e606e (diff) | |
download | dbus-564056e21e858b2402bd5d5a2eedb15380261732.tar.gz |
dbus-daemon: Implement signal 'ActivatableServicesChanged'
After any reload of the activatable service files the mentioned signal is
emitted to the current bus to inform clients.
The calls to signal emmission have not been implemented in the platform
specific functions _dbus_daemon_report_reloaded() to avoid duplicate
implementations.
Fixes #376
Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
Diffstat (limited to 'bus/bus.c')
-rw-r--r-- | bus/bus.c | 70 |
1 files changed, 70 insertions, 0 deletions
@@ -30,6 +30,7 @@ #include "activation.h" #include "connection.h" #include "containers.h" +#include "dispatch.h" #include "services.h" #include "utils.h" #include "policy.h" @@ -1075,6 +1076,66 @@ bus_context_get_id (BusContext *context, return _dbus_uuid_encode (&context->uuid, uuid); } +/** + * Send signal to the buses that the activatable services may be changed + * + * @param context bus context to use + * @param error the error to set, if NULL no error will be set + * @return #FALSE if an error occurred, the reason is returned in \p error + */ +static dbus_bool_t +bus_context_send_activatable_services_changed (BusContext *context, + DBusError *error) +{ + DBusMessage *message; + BusTransaction *transaction; + dbus_bool_t retval = FALSE; + + _DBUS_ASSERT_ERROR_IS_CLEAR (error); + + transaction = bus_transaction_new (context); + if (transaction == NULL) + { + BUS_SET_OOM (error); + return FALSE; + } + + message = dbus_message_new_signal (DBUS_PATH_DBUS, + DBUS_INTERFACE_DBUS, + "ActivatableServicesChanged"); + + if (message == NULL) + { + BUS_SET_OOM (error); + goto out; + } + + if (!dbus_message_set_sender (message, DBUS_SERVICE_DBUS)) + { + BUS_SET_OOM (error); + goto out; + } + + if (!bus_transaction_capture (transaction, NULL, NULL, message)) + { + BUS_SET_OOM (error); + goto out; + } + + retval = bus_dispatch_matches (transaction, NULL, NULL, message, error); + +out: + if (transaction != NULL) + { + if (retval) + bus_transaction_execute_and_free (transaction); + else + bus_transaction_cancel_and_free (transaction); + } + dbus_clear_message (&message); + return retval; +} + dbus_bool_t bus_context_reload_config (BusContext *context, DBusError *error) @@ -1116,6 +1177,15 @@ bus_context_reload_config (BusContext *context, if (parser != NULL) bus_config_parser_unref (parser); + { + DBusError local_error = DBUS_ERROR_INIT; + + if (!bus_context_send_activatable_services_changed (context, &local_error)) + bus_context_log (context, DBUS_SYSTEM_LOG_INFO, "Unable to send signal that configuration has been reloaded: %s", local_error.message); + + dbus_error_free (&local_error); + } + _dbus_daemon_report_reloaded (); return ret; } |