diff options
author | PhylLu <Phyllis.Lu@quantatw.com> | 2023-10-11 03:41:29 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2023-10-11 17:06:16 +0200 |
commit | 4f10005e175bef552c8dabc08dbb6055ae6dd3a4 (patch) | |
tree | bdac64f56bcf8df9df89caa1a80c194aaf1b7436 /src/timedate | |
parent | dns-domain: fix the RFC reference (diff) | |
download | systemd-4f10005e175bef552c8dabc08dbb6055ae6dd3a4.tar.xz systemd-4f10005e175bef552c8dabc08dbb6055ae6dd3a4.zip |
timedate: Extend timeout for setting NTP
One of the steps in setting up NTP is to enable/disable the
'systemd-timesyncd.service' and then perform a daemon reload.
we use an extra-long timeout for reload in timedated as same as used in
systemd daemon reload to avoiding certain situation have longer reload
times (which exceed the 25 second default timeout used for
dbus-communication), potentially leading to setting NTP failure.
Diffstat (limited to 'src/timedate')
-rw-r--r-- | src/timedate/timedatectl.c | 12 | ||||
-rw-r--r-- | src/timedate/timedated.c | 3 |
2 files changed, 13 insertions, 2 deletions
diff --git a/src/timedate/timedatectl.c b/src/timedate/timedatectl.c index e1feeac061..93e69a28b0 100644 --- a/src/timedate/timedatectl.c +++ b/src/timedate/timedatectl.c @@ -275,6 +275,7 @@ static int set_local_rtc(int argc, char **argv, void *userdata) { } static int set_ntp(int argc, char **argv, void *userdata) { + _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL; _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; sd_bus *bus = userdata; int b, r; @@ -285,7 +286,16 @@ static int set_ntp(int argc, char **argv, void *userdata) { if (b < 0) return log_error_errno(b, "Failed to parse NTP setting '%s': %m", argv[1]); - r = bus_call_method(bus, bus_timedate, "SetNTP", &error, NULL, "bb", b, arg_ask_password); + r = bus_message_new_method_call(bus, &m, bus_timedate, "SetNTP"); + if (r < 0) + return bus_log_create_error(r); + + r = sd_bus_message_append(m, "bb", b, arg_ask_password); + 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 set ntp: %s", bus_error_message(&error, r)); diff --git a/src/timedate/timedated.c b/src/timedate/timedated.c index 5ac7c9f8b2..6406d6fefd 100644 --- a/src/timedate/timedated.c +++ b/src/timedate/timedated.c @@ -18,6 +18,7 @@ #include "bus-log-control-api.h" #include "bus-map-properties.h" #include "bus-polkit.h" +#include "bus-unit-util.h" #include "clock-util.h" #include "conf-files.h" #include "constants.h" @@ -545,7 +546,7 @@ static int unit_enable_or_disable(UnitStatusInfo *u, sd_bus *bus, sd_bus_error * if (r < 0) return r; - r = bus_call_method(bus, bus_systemd_mgr, "Reload", error, NULL, NULL); + r = bus_service_manager_reload(bus); if (r < 0) return r; |