From: Lennart Poettering Date: Wed, 24 Oct 2018 11:15:24 +0000 (+0200) Subject: sleep: when we can't hibernate on suspend-then-hibernate, fall back to suspend again X-Git-Tag: v240~475^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=refs%2Fpull%2F10504%2Fhead;p=thirdparty%2Fsystemd.git sleep: when we can't hibernate on suspend-then-hibernate, fall back to suspend again Let's make this a bit safer, and try hard to return to sleep, if we can at all. Fixes: #10212 --- diff --git a/src/sleep/sleep.c b/src/sleep/sleep.c index e3b72a768d5..a4eba598514 100644 --- a/src/sleep/sleep.c +++ b/src/sleep/sleep.c @@ -263,7 +263,17 @@ static int execute_s2h(usec_t hibernate_delay_sec) { return 0; /* If woken up after alarm time, hibernate */ - return execute(hibernate_modes, hibernate_states); + r = execute(hibernate_modes, hibernate_states); + if (r < 0) { + log_notice("Couldn't hibernate, will try to suspend again."); + r = execute(suspend_modes, suspend_states); + if (r < 0) { + log_notice("Could neither hibernate nor suspend again, giving up."); + return r; + } + } + + return 0; } static int help(void) {