From: Zbigniew Jędrzejewski-Szmek Date: Fri, 22 Jul 2022 20:29:00 +0000 (+0200) Subject: Use a common define for the reload timeout X-Git-Tag: v252-rc1~417^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5df2a4a6e0b3e8574e067d0252b954a5e002e751;p=thirdparty%2Fsystemd.git Use a common define for the reload timeout --- diff --git a/src/basic/def.h b/src/basic/def.h index 0a1ae023a37..2b4de29021a 100644 --- a/src/basic/def.h +++ b/src/basic/def.h @@ -5,6 +5,11 @@ #define DEFAULT_RESTART_USEC (100*USEC_PER_MSEC) #define DEFAULT_CONFIRM_USEC (30*USEC_PER_SEC) +/* We use an extra-long timeout for the reload. This is because a reload or reexec means generators are rerun + * which are timed out after DEFAULT_TIMEOUT_USEC. Let's use twice that time here, so that the generators can + * have their timeout, and for everything else there's the same time budget in place. */ +#define DAEMON_RELOAD_TIMEOUT_SEC (DEFAULT_TIMEOUT_USEC * 2) + #define DEFAULT_START_LIMIT_INTERVAL (10*USEC_PER_SEC) #define DEFAULT_START_LIMIT_BURST 5 diff --git a/src/portable/portablectl.c b/src/portable/portablectl.c index 0fc3a64d71c..4005a5c796d 100644 --- a/src/portable/portablectl.c +++ b/src/portable/portablectl.c @@ -249,7 +249,7 @@ static int maybe_reload(sd_bus **bus) { return bus_log_create_error(r); /* Reloading the daemon may take long, hence set a longer timeout here */ - r = sd_bus_call(*bus, m, DEFAULT_TIMEOUT_USEC * 2, &error, NULL); + r = sd_bus_call(*bus, m, DAEMON_RELOAD_TIMEOUT_SEC, &error, NULL); if (r < 0) return log_error_errno(r, "Failed to reload daemon: %s", bus_error_message(&error, r)); diff --git a/src/sulogin-shell/sulogin-shell.c b/src/sulogin-shell/sulogin-shell.c index 148e8acd73e..718cf37607f 100644 --- a/src/sulogin-shell/sulogin-shell.c +++ b/src/sulogin-shell/sulogin-shell.c @@ -34,11 +34,8 @@ static int reload_manager(sd_bus *bus) { if (r < 0) return bus_log_create_error(r); - /* Note we use an extra-long timeout here. This is because a reload or reexec means generators are rerun which - * are timed out after DEFAULT_TIMEOUT_USEC. Let's use twice that time here, so that the generators can have - * their timeout, and for everything else there's the same time budget in place. */ - - r = sd_bus_call(bus, m, DEFAULT_TIMEOUT_USEC * 2, &error, NULL); + /* 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 daemon: %s", bus_error_message(&error, r)); diff --git a/src/systemctl/systemctl-daemon-reload.c b/src/systemctl/systemctl-daemon-reload.c index 33de7d161e2..4f025ac4d2e 100644 --- a/src/systemctl/systemctl-daemon-reload.c +++ b/src/systemctl/systemctl-daemon-reload.c @@ -37,12 +37,8 @@ int daemon_reload(enum action action, bool graceful) { if (r < 0) return bus_log_create_error(r); - /* Note we use an extra-long timeout here. This is because a reload or reexec means generators are - * rerun which are timed out after DEFAULT_TIMEOUT_USEC. Let's use twice that time here, so that the - * generators can have their timeout, and for everything else there's the same time budget in - * place. */ - - r = sd_bus_call(bus, m, DEFAULT_TIMEOUT_USEC * 2, &error, NULL); + /* Reloading the daemon may take long, hence set a longer timeout here */ + r = sd_bus_call(bus, m, DAEMON_RELOAD_TIMEOUT_SEC, &error, NULL); /* On reexecution, we expect a disconnect, not a reply */ if (IN_SET(r, -ETIMEDOUT, -ECONNRESET) && action == ACTION_REEXEC)