daandemeyer / rpms / systemd

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