e43452d
From 3e750716de6acad59112a34d3d79f50da680d023 Mon Sep 17 00:00:00 2001
e43452d
From: Lennart Poettering <lennart@poettering.net>
e43452d
Date: Tue, 1 Nov 2011 18:18:17 +0100
f1996ec
Subject: [PATCH] initctl: don't use dbus connection after PID 1 got respawned
e43452d
e43452d
After reexec PID 1 our bus connection is invalidated. Hence don't try to
e43452d
reuse it, just terminate so that when we are spawned the next time we
e43452d
just get a new one.
e43452d
e43452d
Spotted by Marti Raudsepp.
e43452d
(cherry picked from commit f632a6634dd4eff041425aa9b3fb48ccfa98c014)
e43452d
---
e43452d
 src/initctl.c |   11 ++++++++++-
e43452d
 1 files changed, 10 insertions(+), 1 deletions(-)
e43452d
e43452d
diff --git a/src/initctl.c b/src/initctl.c
e43452d
index eaa717a..097c85f 100644
e43452d
--- a/src/initctl.c
e43452d
+++ b/src/initctl.c
e43452d
@@ -56,6 +56,8 @@ typedef struct Server {
e43452d
         unsigned n_fifos;
e43452d
 
e43452d
         DBusConnection *bus;
e43452d
+
e43452d
+        bool quit;
e43452d
 } Server;
e43452d
 
e43452d
 struct Fifo {
e43452d
@@ -174,6 +176,13 @@ static void request_process(Server *s, const struct init_request *req) {
e43452d
                         case 'U':
e43452d
                                 if (kill(1, SIGTERM) < 0)
e43452d
                                         log_error("kill() failed: %m");
e43452d
+
e43452d
+                                /* The bus connection will be
e43452d
+                                 * terminated if PID 1 is reexecuted,
e43452d
+                                 * hence let's just exit here, and
e43452d
+                                 * rely on that we'll be restarted on
e43452d
+                                 * the next request */
e43452d
+                                s->quit = true;
e43452d
                                 break;
e43452d
 
e43452d
                         case 'q':
e43452d
@@ -404,7 +413,7 @@ int main(int argc, char *argv[]) {
e43452d
                   "READY=1\n"
e43452d
                   "STATUS=Processing requests...");
e43452d
 
e43452d
-        for (;;) {
e43452d
+        while (!server.quit) {
e43452d
                 struct epoll_event event;
e43452d
                 int k;
e43452d
 
e43452d
-- 
e43452d
1.7.7.5
e43452d