summaryrefslogtreecommitdiff
path: root/src/sleep
diff options
context:
space:
mode:
authormsizanoen1 <msizanoen@qtmlabs.xyz>2022-12-07 23:22:05 +0700
committermsizanoen1 <msizanoen@qtmlabs.xyz>2022-12-08 12:58:00 +0100
commit432a32117506657186e16bd8e0642bbb30326bc4 (patch)
tree1dba254b662524c8ba12b300cf6441ae5d4c976e /src/sleep
parent7fcd26978484b9a328b976799fbca038430f942f (diff)
downloadsystemd-432a32117506657186e16bd8e0642bbb30326bc4.tar.gz
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.
Diffstat (limited to 'src/sleep')
-rw-r--r--src/sleep/sleep.c3
1 files changed, 3 insertions, 0 deletions
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));