summaryrefslogtreecommitdiff
path: root/src/sleep
diff options
context:
space:
mode:
authorMike Yuan <me@yhndnzj.com>2023-02-20 20:12:19 +0800
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2023-02-21 20:48:33 +0100
commite0b3a70fabb871bf55678e9e177445b1df2aee88 (patch)
treeae28c74109133b4db42cd1ab6c17f498280c1e41 /src/sleep
parentf8979e869812988835f6951fb73a68e30a4c608c (diff)
downloadsystemd-e0b3a70fabb871bf55678e9e177445b1df2aee88.tar.gz
sleep: check if we're on AC power before checking battery capacity
Before this commit, battery_is_low() returns true if there's no battery on the system. It's now modified to check if the system is on AC power first, and returns false early if that's the case. Fixes #26492
Diffstat (limited to 'src/sleep')
-rw-r--r--src/sleep/sleep.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/sleep/sleep.c b/src/sleep/sleep.c
index 9018188cba..f7fee4a14c 100644
--- a/src/sleep/sleep.c
+++ b/src/sleep/sleep.c
@@ -274,7 +274,7 @@ static int custom_timer_suspend(const SleepConfig *sleep_config) {
hibernate_timestamp = usec_add(now(CLOCK_BOOTTIME), sleep_config->hibernate_delay_usec);
- while (battery_is_low() == 0) {
+ while (battery_is_discharging_and_low() == 0) {
_cleanup_hashmap_free_ Hashmap *last_capacity = NULL, *current_capacity = NULL;
_cleanup_close_ int tfd = -EBADF;
struct itimerspec ts = {};