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