anitazha / rpms / systemd

Forked from rpms/systemd 3 years ago
Clone

Blame SOURCES/0208-logind-order-all-scopes-after-both-systemd-logind.se.patch

572a44
From 10c5a4fec72a42369af812769802be974af3a012 Mon Sep 17 00:00:00 2001
572a44
From: Michal Sekletar <msekleta@redhat.com>
572a44
Date: Mon, 3 Mar 2014 16:07:39 +0100
572a44
Subject: [PATCH] logind: order all scopes after both systemd-logind.service
572a44
 and systemd-user-sessions.service
572a44
572a44
This way at shutdown we can be sure that the sessions go away before the
572a44
network.
572a44
572a44
Based-on: ba4c5d93b73ef7bba0ae0c6bf2b36a42360f7a34
572a44
---
572a44
 src/login/logind-dbus.c    | 17 ++++++++++++++---
572a44
 src/login/logind-session.c |  2 +-
572a44
 src/login/logind.h         |  2 +-
572a44
 3 files changed, 16 insertions(+), 5 deletions(-)
572a44
572a44
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
572a44
index 8de301e..a68e9b4 100644
572a44
--- a/src/login/logind-dbus.c
572a44
+++ b/src/login/logind-dbus.c
572a44
@@ -2545,10 +2545,11 @@ int manager_start_scope(
572a44
                 const char *slice,
572a44
                 const char *description,
572a44
                 const char *after,
572a44
+                const char *after2,
572a44
                 DBusError *error,
572a44
                 char **job) {
572a44
 
572a44
-        const char *timeout_stop_property = "TimeoutStopUSec", *send_sighup_property = "SendSIGHUP", *pids_property = "PIDs";
572a44
+        const char *timeout_stop_property = "TimeoutStopUSec", *send_sighup_property = "SendSIGHUP", *pids_property = "PIDs", *after_property = "After";
572a44
         _cleanup_dbus_message_unref_ DBusMessage *m = NULL, *reply = NULL;
572a44
         DBusMessageIter iter, sub, sub2, sub3, sub4;
572a44
         uint64_t timeout = 500 * USEC_PER_MSEC;
572a44
@@ -2603,8 +2604,6 @@ int manager_start_scope(
572a44
         }
572a44
 
572a44
         if (!isempty(after)) {
572a44
-                const char *after_property = "After";
572a44
-
572a44
                 if (!dbus_message_iter_open_container(&sub, DBUS_TYPE_STRUCT, NULL, &sub2) ||
572a44
                     !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_STRING, &after_property) ||
572a44
                     !dbus_message_iter_open_container(&sub2, DBUS_TYPE_VARIANT, "as", &sub3) ||
572a44
@@ -2616,6 +2615,18 @@ int manager_start_scope(
572a44
                         return log_oom();
572a44
         }
572a44
 
572a44
+        if (!isempty(after2)) {
572a44
+                if (!dbus_message_iter_open_container(&sub, DBUS_TYPE_STRUCT, NULL, &sub2) ||
572a44
+                    !dbus_message_iter_append_basic(&sub2, DBUS_TYPE_STRING, &after_property) ||
572a44
+                    !dbus_message_iter_open_container(&sub2, DBUS_TYPE_VARIANT, "as", &sub3) ||
572a44
+                    !dbus_message_iter_open_container(&sub3, DBUS_TYPE_ARRAY, "s", &sub4) ||
572a44
+                    !dbus_message_iter_append_basic(&sub4, DBUS_TYPE_STRING, &after2) ||
572a44
+                    !dbus_message_iter_close_container(&sub3, &sub4) ||
572a44
+                    !dbus_message_iter_close_container(&sub2, &sub3) ||
572a44
+                    !dbus_message_iter_close_container(&sub, &sub2))
572a44
+                        return log_oom();
572a44
+        }
572a44
+
572a44
         /* cgroup empty notification is not available in containers
572a44
          * currently. To make this less problematic, let's shorten the
572a44
          * stop timeout for sessions, so that we don't wait
572a44
diff --git a/src/login/logind-session.c b/src/login/logind-session.c
572a44
index 78e6d74..2bac0a2 100644
572a44
--- a/src/login/logind-session.c
572a44
+++ b/src/login/logind-session.c
572a44
@@ -518,7 +518,7 @@ static int session_start_scope(Session *s) {
572a44
                 if (!scope)
572a44
                         return log_oom();
572a44
 
572a44
-                r = manager_start_scope(s->manager, scope, s->leader, s->user->slice, description, "systemd-logind.service", &error, &job;;
572a44
+                r = manager_start_scope(s->manager, scope, s->leader, s->user->slice, description, "systemd-logind.service", "systemd-user-session.service", &error, &job;;
572a44
                 if (r < 0) {
572a44
                         log_error("Failed to start session scope %s: %s %s",
572a44
                                   scope, bus_error(&error, r), error.name);
572a44
diff --git a/src/login/logind.h b/src/login/logind.h
572a44
index 0d2248f..540572f 100644
572a44
--- a/src/login/logind.h
572a44
+++ b/src/login/logind.h
572a44
@@ -184,7 +184,7 @@ int manager_send_changed(Manager *manager, const char *properties);
572a44
 
572a44
 int manager_dispatch_delayed(Manager *manager);
572a44
 
572a44
-int manager_start_scope(Manager *manager, const char *scope, pid_t pid, const char *slice, const char *description, const char *after, DBusError *error, char **job);
572a44
+int manager_start_scope(Manager *manager, const char *scope, pid_t pid, const char *slice, const char *description, const char *after, const char *after2, DBusError *error, char **job);
572a44
 int manager_start_unit(Manager *manager, const char *unit, DBusError *error, char **job);
572a44
 int manager_stop_unit(Manager *manager, const char *unit, DBusError *error, char **job);
572a44
 int manager_abandon_scope(Manager *manager, const char *scope, DBusError *error);