[op5-users] [PATCH] module.c: Make sure we are always reaping or connecting for ipc
Sean Millichamp
sean at bruenor.org
Tue Nov 3 15:50:36 CET 2009
Currently, Merlin calls mrm_ipc_connect() and mrm_ipc_reap() at
startup. mrm_ipc_connect will loop (via scheduled event) until
a successful connection is achieved, but never check to make
sure that the reaper events are scheduled. mrm_ipc_reap,
however, will immediately abort if there is no active ipc
connection without rescheduling any more reaper or connection
attempts. This is a common situation if Nagios is started
before Merlin.
This patch makes sure that mrm_ipc_connect() is called in
post_init_config() and leaves the responsibility of starting
reaper in mrm_ipc_connect(). Conversely, if mrm_ipc_reap()
discovers that the ipc connection is no longer valid (and can't
immediately reconnect) then it calls mrm_ipc_connect to reschedule
the connect attempt loops.
Signed-off-by: Sean Millichamp <sean at bruenor.org>
---
module.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/module.c b/module.c
index 152acde..c0f6d74 100644
--- a/module.c
+++ b/module.c
@@ -6,6 +6,8 @@
int cb_handler(int, void *);
time_t merlin_should_send_paths = 1;
+static int mrm_ipc_connect(void *discard);
+
/** code start **/
extern hostgroup *hostgroup_list;
#define mrm_reap_interval 5
@@ -102,6 +104,9 @@ static int mrm_ipc_reap(void *discard)
if (!ipc_is_connected(0)) {
linfo("ipc is not connected. ipc event reaping aborted");
+ ldebug("Scheduling mrm_ipc_connect to reattempt to connect to ipc");
+ schedule_new_event(EVENT_USER_FUNCTION, TRUE, time(NULL) + 10, FALSE,
+ 0, NULL, FALSE, mrm_ipc_connect, NULL, 0);
return 0;
}
else
@@ -349,6 +354,7 @@ static int mrm_ipc_connect(void *discard)
}
else {
linfo("ipc successfully connected");
+ mrm_ipc_reap(NULL);
}
return result;
@@ -376,7 +382,6 @@ static int post_config_init(int cb, void *ds)
create_object_lists();
mrm_ipc_connect(NULL);
- mrm_ipc_reap(NULL);
send_paths();
/*
--
1.6.2.5
More information about the op5-users
mailing list