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