daandemeyer / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
698723
From 83c49a5e54dffc3dfa85b79f6375cd0a42a4ff76 Mon Sep 17 00:00:00 2001
698723
From: Lennart Poettering <lennart@poettering.net>
698723
Date: Mon, 6 Aug 2018 19:34:39 +0200
698723
Subject: [PATCH] logind: introduce little helper that checks whether a session
698723
 is ready
698723
698723
(cherry picked from commit b1951bc83ffbbb92ba4de7b9cba845421c2f35b1)
698723
698723
Related: #1642460
698723
---
698723
 src/login/logind-session-dbus.c | 17 ++++++++++++-----
698723
 1 file changed, 12 insertions(+), 5 deletions(-)
698723
698723
diff --git a/src/login/logind-session-dbus.c b/src/login/logind-session-dbus.c
698723
index 88a2d33dc8..03585b7f8e 100644
698723
--- a/src/login/logind-session-dbus.c
698723
+++ b/src/login/logind-session-dbus.c
698723
@@ -704,6 +704,15 @@ int session_send_lock_all(Manager *m, bool lock) {
698723
         return r;
698723
 }
698723
 
698723
+static bool session_ready(Session *s) {
698723
+        assert(s);
698723
+
698723
+        /* Returns true when the session is ready, i.e. all jobs we enqueued for it are done (regardless if successful or not) */
698723
+
698723
+        return !s->scope_job &&
698723
+                !s->user->service_job;
698723
+}
698723
+
698723
 int session_send_create_reply(Session *s, sd_bus_error *error) {
698723
         _cleanup_(sd_bus_message_unrefp) sd_bus_message *c = NULL;
698723
         _cleanup_close_ int fifo_fd = -1;
698723
@@ -711,14 +720,13 @@ int session_send_create_reply(Session *s, sd_bus_error *error) {
698723
 
698723
         assert(s);
698723
 
698723
-        /* This is called after the session scope and the user service
698723
-         * were successfully created, and finishes where
698723
+        /* This is called after the session scope and the user service were successfully created, and finishes where
698723
          * bus_manager_create_session() left off. */
698723
 
698723
         if (!s->create_message)
698723
                 return 0;
698723
 
698723
-        if (!sd_bus_error_is_set(error) && (s->scope_job || s->user->service_job))
698723
+        if (!sd_bus_error_is_set(error) && !session_ready(s))
698723
                 return 0;
698723
 
698723
         c = s->create_message;
698723
@@ -731,8 +739,7 @@ int session_send_create_reply(Session *s, sd_bus_error *error) {
698723
         if (fifo_fd < 0)
698723
                 return fifo_fd;
698723
 
698723
-        /* Update the session state file before we notify the client
698723
-         * about the result. */
698723
+        /* Update the session state file before we notify the client about the result. */
698723
         session_save(s);
698723
 
698723
         p = session_bus_path(s);