diff options
author | Lennart Poettering <lennart@poettering.net> | 2018-10-24 13:15:24 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2018-10-24 14:44:14 +0200 |
commit | f05e1ae66601d4b2c8666c8fa91b46287ae93d86 (patch) | |
tree | 0a3fa35babaca2d2bf251a46b728e2d379b46c39 | |
parent | 14250f0942b0c1122a35d678e73945d7adf9cfa0 (diff) | |
download | systemd-f05e1ae66601d4b2c8666c8fa91b46287ae93d86.tar.gz |
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
-rw-r--r-- | src/sleep/sleep.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/sleep/sleep.c b/src/sleep/sleep.c index e3b72a768d..a4eba59851 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) { |