From 5427b642f3f5da05c14db63c355544b794e80483 Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Fri, 14 Jan 2011 09:46:04 +1100 Subject: [PATCH] We can not always rely on the recovery daemon pinging us in a timely manner so we need a "ticker" in the main ctdbd daemon too to ensure we get at least one event to process every second. This will improve the accuracy of "Time jumped" messages and remove false positives when the recovery daemon is "slow". --- server/ctdb_daemon.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/server/ctdb_daemon.c b/server/ctdb_daemon.c index 72c72932..362f1cee 100644 --- a/server/ctdb_daemon.c +++ b/server/ctdb_daemon.c @@ -43,6 +43,33 @@ static void print_exit_message(void) DEBUG(DEBUG_NOTICE,("CTDB daemon shutting down\n")); } + + +static void ctdb_time_tick(struct event_context *ev, struct timed_event *te, + struct timeval t, void *private_data) +{ + struct ctdb_context *ctdb = talloc_get_type(private_data, struct ctdb_context); + + if (getpid() != ctdbd_pid) { + return; + } + + event_add_timed(ctdb->ev, ctdb, + timeval_current_ofs(1, 0), + ctdb_time_tick, ctdb); +} + +/* Used to trigger a dummy event once per second, to make + * detection of hangs more reliable. + */ +static void ctdb_start_time_tickd(struct ctdb_context *ctdb) +{ + event_add_timed(ctdb->ev, ctdb, + timeval_current_ofs(1, 0), + ctdb_time_tick, ctdb); +} + + /* called when the "startup" event script has finished */ static void ctdb_start_transport(struct ctdb_context *ctdb) { @@ -77,6 +104,9 @@ static void ctdb_start_transport(struct ctdb_context *ctdb) /* start listening for recovery daemon pings */ ctdb_control_recd_ping(ctdb); + + /* start listening to timer ticks */ + ctdb_start_time_tickd(ctdb); } static void block_signal(int signum) -- 2.34.1