summaryrefslogtreecommitdiff
path: root/src/login
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2012-10-28 17:25:23 +0100
committerLennart Poettering <lennart@poettering.net>2012-10-30 03:40:42 +0100
commit7ba643863116cd0b5abf048e53321f93e5743f69 (patch)
tree1728536e8916d522cb4378b3777b034e74c2a116 /src/login
parentfaf22b6559a747ca6b2185b816d60cce376b11c8 (diff)
logind: unify all session lock loop
Diffstat (limited to 'src/login')
-rw-r--r--src/login/logind-button.c19
-rw-r--r--src/login/logind-dbus.c11
-rw-r--r--src/login/logind-session-dbus.c18
-rw-r--r--src/login/logind-session.h1
4 files changed, 28 insertions, 21 deletions
diff --git a/src/login/logind-button.c b/src/login/logind-button.c
index 778852698f..8bbd731ae4 100644
--- a/src/login/logind-button.c
+++ b/src/login/logind-button.c
@@ -150,18 +150,6 @@ fail:
return r;
}
-static int lock_sessions(Manager *m) {
- Iterator i;
- Session *session;
-
- log_info("Locking sessions...");
-
- HASHMAP_FOREACH(session, m->sessions, i)
- session_send_lock(session, true);
-
- return 1;
-}
-
static int button_handle(
Button *b,
InhibitWhat inhibit_key,
@@ -208,8 +196,11 @@ static int button_handle(
}
/* Locking is handled differently from the rest. */
- if (handle == HANDLE_LOCK)
- return lock_sessions(b->manager);
+ if (handle == HANDLE_LOCK) {
+ log_info("Locking sessions...");
+ session_send_lock_all(b->manager, true);
+ return 1;
+ }
inhibit_operation = handle == HANDLE_SUSPEND || handle == HANDLE_HIBERNATE || handle == HANDLE_HYBRID_SLEEP ? INHIBIT_SLEEP : INHIBIT_SHUTDOWN;
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
index 3bcb91bf13..4326e5b87c 100644
--- a/src/login/logind-dbus.c
+++ b/src/login/logind-dbus.c
@@ -1812,7 +1812,7 @@ static DBusHandlerResult manager_message_handler(
session = hashmap_get(m->sessions, name);
if (!session)
- return bus_send_error_reply(connection, message, &error, -ENOENT);
+ return bus_send_error_reply(connection, message, NULL, -ENOENT);
if (session_send_lock(session, streq(dbus_message_get_member(message), "LockSession")) < 0)
goto oom;
@@ -1822,12 +1822,9 @@ static DBusHandlerResult manager_message_handler(
goto oom;
} else if (dbus_message_is_method_call(message, "org.freedesktop.login1.Manager", "LockSessions")) {
- Session *session;
- Iterator i;
-
- HASHMAP_FOREACH(session, m->sessions, i)
- if (session_send_lock(session, true) < 0)
- goto oom;
+ r = session_send_lock_all(m, true);
+ if (r < 0)
+ bus_send_error_reply(connection, message, NULL, r);
reply = dbus_message_new_method_return(message);
if (!reply)
diff --git a/src/login/logind-session-dbus.c b/src/login/logind-session-dbus.c
index 26c853e4ee..ef73cd434a 100644
--- a/src/login/logind-session-dbus.c
+++ b/src/login/logind-session-dbus.c
@@ -570,3 +570,21 @@ int session_send_lock(Session *s, bool lock) {
return 0;
}
+
+int session_send_lock_all(Manager *m, bool lock) {
+ Session *session;
+ Iterator i;
+ int r = 0;
+
+ assert(m);
+
+ HASHMAP_FOREACH(session, m->sessions, i) {
+ int k;
+
+ k = session_send_lock(session, lock);
+ if (k < 0)
+ r = k;
+ }
+
+ return r;
+}
diff --git a/src/login/logind-session.h b/src/login/logind-session.h
index bfa4abd690..7598afa618 100644
--- a/src/login/logind-session.h
+++ b/src/login/logind-session.h
@@ -132,6 +132,7 @@ extern const DBusObjectPathVTable bus_session_vtable;
int session_send_signal(Session *s, bool new_session);
int session_send_changed(Session *s, const char *properties);
int session_send_lock(Session *s, bool lock);
+int session_send_lock_all(Manager *m, bool lock);
const char* session_state_to_string(SessionState t);
SessionState session_state_from_string(const char *s);