Blob Blame History Raw
From 12cbba5545aefa59e27f683e17e05b8e80063718 Mon Sep 17 00:00:00 2001
From: Stephen Gallagher <sgallagh@redhat.com>
Date: Fri, 19 Jun 2009 11:28:49 -0400
Subject: [PATCH] Protect against segfault in service_signal_reload

There is a potential race condition where the monitor may attempt
to signal a reload of a child process before the communication
sbus channel is available. If this happens, we will just exit this
function and let the monitor kill and restart the child process.
---
 server/monitor/monitor.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/server/monitor/monitor.c b/server/monitor/monitor.c
index e4fca25..5cc73c8 100644
--- a/server/monitor/monitor.c
+++ b/server/monitor/monitor.c
@@ -525,6 +525,15 @@ static int service_signal_reload(struct mt_svc *svc)
         return EOK;
     }
 
+    if (!svc->mt_conn) {
+        /* Avoid a race condition where we are trying to
+         * order a service to reload that hasn't started
+         * yet.
+         */
+        DEBUG(1,("Could not reload service [%s].\n", svc->name));
+        return EIO;
+    }
+
     conn = sbus_get_connection(svc->mt_conn->conn_ctx);
     msg = dbus_message_new_method_call(NULL,
                                        SERVICE_PATH,
-- 
1.6.2.2