From: PhylLu Date: Wed, 11 Oct 2023 01:41:29 +0000 (+0800) Subject: timedate: Extend timeout for setting NTP X-Git-Tag: v255-rc1~272 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4f10005e175bef552c8dabc08dbb6055ae6dd3a4;p=thirdparty%2Fsystemd.git 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. --- diff --git a/src/timedate/timedatectl.c b/src/timedate/timedatectl.c index e1feeac0615..93e69a28b0e 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 5ac7c9f8b24..6406d6fefd5 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;