summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-08-06 19:34:39 +0200
committerSven Eden <sven.eden@prydeworx.com>2018-10-29 10:18:35 +0100
commit4ca729a0f51264a169b209d879661319b81ded51 (patch)
tree46da065fa2f9a21dceca764fbe93b4dcb1234872
parent49352cef7194fd620d415f1aba251cd411eab70f (diff)
logind: introduce little helper that checks whether a session is ready
(cherry picked from commit b1951bc83ffbbb92ba4de7b9cba845421c2f35b1)
-rw-r--r--src/login/logind-session-dbus.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/login/logind-session-dbus.c b/src/login/logind-session-dbus.c
index 0e2cde727..b50f4440e 100644
--- a/src/login/logind-session-dbus.c
+++ b/src/login/logind-session-dbus.c
@@ -689,6 +689,15 @@ int session_send_lock_all(Manager *m, bool lock) {
return r;
}
+static bool session_ready(Session *s) {
+ assert(s);
+
+ /* Returns true when the session is ready, i.e. all jobs we enqueued for it are done (regardless if successful or not) */
+
+ return !s->scope_job &&
+ !s->user->service_job;
+}
+
int session_send_create_reply(Session *s, sd_bus_error *error) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *c = NULL;
_cleanup_close_ int fifo_fd = -1;
@@ -696,15 +705,14 @@ int session_send_create_reply(Session *s, sd_bus_error *error) {
assert(s);
- /* This is called after the session scope and the user service
- * were successfully created, and finishes where
+ /* This is called after the session scope and the user service were successfully created, and finishes where
* bus_manager_create_session() left off. */
if (!s->create_message)
return 0;
#if 0 /// elogind does not support scope and service jobs
- if (!sd_bus_error_is_set(error) && (s->scope_job || s->user->service_job))
+ if (!sd_bus_error_is_set(error) && !session_ready(s))
return 0;
#endif // 0
@@ -716,8 +724,7 @@ int session_send_create_reply(Session *s, sd_bus_error *error) {
if (fifo_fd < 0)
return fifo_fd;
- /* Update the session state file before we notify the client
- * about the result. */
+ /* Update the session state file before we notify the client about the result. */
session_save(s);
#if 1 /// Additionally elogind saves the user state file