From b7d98dfd7346776fa875dd32eb47b92f7552cbf6 Mon Sep 17 00:00:00 2001 From: Stephen Gallagher Date: Fri, 19 Jun 2009 11:28:49 -0400 Subject: [PATCH 2/2] 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..7e5aacb 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]. Deferring.\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