Merge pull request #28343 from poettering/daemon-reload-common

tree-wide: add common implementation of Reload() bus call to PID 1
This commit is contained in:
Yu Watanabe
2023-07-11 08:42:19 +09:00
committed by GitHub
14 changed files with 54 additions and 77 deletions
+20
View File
@@ -3,6 +3,7 @@
#include "af-list.h"
#include "alloc-util.h"
#include "bus-error.h"
#include "bus-locator.h"
#include "bus-unit-util.h"
#include "bus-util.h"
#include "cap-list.h"
@@ -2811,3 +2812,22 @@ int unit_info_compare(const UnitInfo *a, const UnitInfo *b) {
/* Third, order by name */
return strcasecmp(a->id, b->id);
}
int bus_service_manager_reload(sd_bus *bus) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
int r;
assert(bus);
r = bus_message_new_method_call(bus, &m, bus_systemd_mgr, "Reload");
if (r < 0)
return bus_log_create_error(r);
/* Reloading the daemon may take long, hence set a longer timeout here */
r = sd_bus_call(bus, m, DAEMON_RELOAD_TIMEOUT_SEC, &error, NULL);
if (r < 0)
return log_error_errno(r, "Failed to reload service manager: %s", bus_error_message(&error, r));
return 0;
}
+2
View File
@@ -30,3 +30,5 @@ int bus_deserialize_and_dump_unit_file_changes(sd_bus_message *m, bool quiet);
int unit_load_state(sd_bus *bus, const char *name, char **load_state);
int unit_info_compare(const UnitInfo *a, const UnitInfo *b);
int bus_service_manager_reload(sd_bus *bus);