From: msizanoen1 Date: Wed, 7 Dec 2022 16:22:05 +0000 (+0700) Subject: core/sleep: set timeout for freeze/thaw operation to 1.5 seconds X-Git-Tag: v253-rc1~330^2~1 X-Git-Url: http://git-history.diyao.me/?a=commitdiff_plain;h=432a32117506657186e16bd8e0642bbb30326bc4;p=systemd%2F.git core/sleep: set timeout for freeze/thaw operation to 1.5 seconds A FreezeUnit operation can hang due to the presence of kernel threads (see last 2 commits). Keeping the default configuration will mean the system will hang for 25 seconds in suspend waiting for the response. 1.5 seconds should be sufficient for most cases. --- diff --git a/src/sleep/sleep.c b/src/sleep/sleep.c index e74e334e33..9b69a2a10d 100644 --- a/src/sleep/sleep.c +++ b/src/sleep/sleep.c @@ -366,6 +366,9 @@ static int freeze_thaw_user_slice(const char **method) { if (r < 0) return log_debug_errno(r, "Failed to open connection to systemd: %m"); + /* Wait for 1.5 seconds at maximum for freeze operation */ + (void) sd_bus_set_method_call_timeout(bus, 1500 * USEC_PER_MSEC); + r = bus_call_method(bus, bus_systemd_mgr, *method, &error, NULL, "s", SPECIAL_USER_SLICE); if (r < 0) return log_debug_errno(r, "Failed to execute operation: %s", bus_error_message(&error, r));