]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - src/login/logind-action.c
Merge pull request #12753 from jrouleau/fix/hibernate-resume-timeout
[thirdparty/systemd.git] / src / login / logind-action.c
index 317e9ef384ca062f3e0e343c45afd50b47743306..4f97e0d9bb50848014abb4e1ae5fa483c6783371 100644 (file)
@@ -8,6 +8,8 @@
 #include "conf-parser.h"
 #include "format-util.h"
 #include "logind-action.h"
+#include "logind-dbus.h"
+#include "logind-session-dbus.h"
 #include "process-util.h"
 #include "sleep-config.h"
 #include "special.h"
@@ -108,12 +110,20 @@ int manager_handle_action(
         else
                 supported = true;
 
+        if (!supported && IN_SET(handle, HANDLE_HIBERNATE, HANDLE_HYBRID_SLEEP, HANDLE_SUSPEND_THEN_HIBERNATE)) {
+                supported = can_sleep("suspend") > 0;
+                if (supported) {
+                        log_notice("Operation '%s' requested but not supported, using regular suspend instead.", handle_action_to_string(handle));
+                        handle = HANDLE_SUSPEND;
+                }
+        }
+
         if (!supported) {
                 log_warning("Requested operation not supported, ignoring.");
                 return -EOPNOTSUPP;
         }
 
-        if (m->action_what) {
+        if (m->action_what > 0) {
                 log_debug("Action already in progress, ignoring.");
                 return -EALREADY;
         }
@@ -129,7 +139,7 @@ int manager_handle_action(
             manager_is_inhibited(m, inhibit_operation, INHIBIT_BLOCK, NULL, false, false, 0, &offending)) {
                 _cleanup_free_ char *comm = NULL, *u = NULL;
 
-                get_process_comm(offending->pid, &comm);
+                (void) get_process_comm(offending->pid, &comm);
                 u = uid_to_name(offending->uid);
 
                 /* If this is just a recheck of the lid switch then don't warn about anything */