From 37861932ce25e9d336e5e6c6fe42071818b4cba9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 7 Jan 2008 16:17:22 +1100 Subject: [PATCH] merge from ronnie (This used to be ctdb commit 0aa6e04438aa5ec727815689baa19544df042cf7) --- ctdb/include/ctdb_private.h | 1 + ctdb/server/ctdb_recoverd.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h index 07dfcbcd68a..9582b6dade2 100644 --- a/ctdb/include/ctdb_private.h +++ b/ctdb/include/ctdb_private.h @@ -366,6 +366,7 @@ struct ctdb_context { struct _trbt_tree_t *server_ids; const char *event_script_dir; const char *default_public_interface; + pid_t ctdbd_pid; pid_t recoverd_pid; bool done_startup; const char *node_ip; diff --git a/ctdb/server/ctdb_recoverd.c b/ctdb/server/ctdb_recoverd.c index fa19a975a82..8dbf46932b2 100644 --- a/ctdb/server/ctdb_recoverd.c +++ b/ctdb/server/ctdb_recoverd.c @@ -1821,6 +1821,12 @@ again: /* we only check for recovery once every second */ ctdb_wait_timeout(ctdb, ctdb->tunable.recover_interval); + /* verify that the main daemon is still running */ + if (kill(ctdb->ctdbd_pid, 0) != 0) { + DEBUG(0,("CTDB daemon is no longer available. Shutting down recovery daemon\n")); + exit(-1); + } + if (rec->election_timeout) { /* an election is in progress */ goto again; @@ -2275,6 +2281,8 @@ int ctdb_start_recoverd(struct ctdb_context *ctdb) return -1; } + ctdb->ctdbd_pid = getpid(); + ctdb->recoverd_pid = fork(); if (ctdb->recoverd_pid == -1) { return -1;