summaryrefslogtreecommitdiff
path: root/src/login/logind-action.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-01-24 04:56:44 +0100
committerLennart Poettering <lennart@poettering.net>2013-01-24 04:56:44 +0100
commitaf9792ac7f39354f80e9006c42c2400c5e41c447 (patch)
tree07fb7a3aa9ebf72f1f4f1654d778538bfd00afd3 /src/login/logind-action.c
parenta4cc3e5ccc0a3033d764a9eb3ae5ee90db560682 (diff)
logind: only allow one shutdown/sleep action to be queued at the same time
This should make sure that closing the lid while shutting down won't suspend the machine but will simply cause the shutdown to complete.
Diffstat (limited to 'src/login/logind-action.c')
-rw-r--r--src/login/logind-action.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/login/logind-action.c b/src/login/logind-action.c
index e1517d6ac2..a796ebe9ec 100644
--- a/src/login/logind-action.c
+++ b/src/login/logind-action.c
@@ -56,10 +56,15 @@ int manager_handle_action(
DBusError error;
int r;
InhibitWhat inhibit_operation;
- bool supported = true;
+ bool supported;
assert(m);
+ if (m->action_job || m->delayed_unit) {
+ log_debug("Action already in progress, ignoring.");
+ return -EALREADY;
+ }
+
/* If the key handling is turned off, don't do anything */
if (handle == HANDLE_IGNORE) {
log_debug("Refusing operation, as it is turned off.");
@@ -74,6 +79,8 @@ int manager_handle_action(
supported = can_sleep("disk") > 0 && can_sleep_disk("suspend") > 0;
else if (handle == HANDLE_KEXEC)
supported = access("/sbin/kexec", X_OK) >= 0;
+ else
+ supported = true;
if (!supported) {
log_warning("Requested operation not supported, ignoring.");