summaryrefslogtreecommitdiffstats
path: root/ctdb/server/ctdb_daemon.c
diff options
context:
space:
mode:
authorRonnie Sahlberg <ronniesahlberg@gmail.com>2011-01-14 09:46:04 +1100
committerRonnie Sahlberg <ronniesahlberg@gmail.com>2011-01-14 09:47:44 +1100
commitd903473d825d906193524b0b7e7f9d1475a33062 (patch)
treec0fa3b8f079c3dff0b5b8dae10ea988481029dba /ctdb/server/ctdb_daemon.c
parent2edbf0b2fb2c473352407b27b15e9c3abfb15be9 (diff)
downloadsamba-d903473d825d906193524b0b7e7f9d1475a33062.tar.gz
samba-d903473d825d906193524b0b7e7f9d1475a33062.tar.xz
samba-d903473d825d906193524b0b7e7f9d1475a33062.zip
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". (This used to be ctdb commit 70154e5e19e219de086b2995d41e8f6e069ee20d)
Diffstat (limited to 'ctdb/server/ctdb_daemon.c')
-rw-r--r--ctdb/server/ctdb_daemon.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/ctdb/server/ctdb_daemon.c b/ctdb/server/ctdb_daemon.c
index 72c7293258c..362f1cee576 100644
--- a/ctdb/server/ctdb_daemon.c
+++ b/ctdb/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)