From 9623c920ab142a3d6dafaaad4086edab9eae63f5 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Wed, 18 Apr 2018 14:44:01 +1000 Subject: [PATCH] ctdb-daemon: Consolidate basic CTDB context initialisation None of this initialisation needs configuration options, so centralise it with the context initialisation. Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- ctdb/server/ctdbd.c | 45 +++++++++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/ctdb/server/ctdbd.c b/ctdb/server/ctdbd.c index 20f82d771f2..f0f0dc91319 100644 --- a/ctdb/server/ctdbd.c +++ b/ctdb/server/ctdbd.c @@ -129,8 +129,33 @@ static struct ctdb_context *ctdb_init(struct tevent_context *ev) return NULL; } + gettimeofday(&ctdb->ctdbd_start_time, NULL); + + gettimeofday(&ctdb->last_recovery_started, NULL); + gettimeofday(&ctdb->last_recovery_finished, NULL); + + ctdb->recovery_mode = CTDB_RECOVERY_NORMAL; + ctdb->recovery_master = (uint32_t)-1; + + ctdb->upcalls = &ctdb_upcalls; + ctdb->statistics.statistics_start_time = timeval_current(); + ctdb->capabilities = CTDB_CAP_DEFAULT; + + /* + * Initialise this node's PNN to the unknown value. This will + * be set to the correct value by either ctdb_add_node() as + * part of loading the nodes file or by + * ctdb_tcp_listen_automatic() when the transport is + * initialised. At some point we should de-optimise this and + * pull it out into ctdb_start_daemon() so it is done clearly + * and only in one place. + */ + ctdb->pnn = CTDB_UNKNOWN_PNN; + + ctdb->do_checkpublicip = true; + return ctdb; } @@ -248,13 +273,6 @@ int main(int argc, const char *argv[]) DEBUG(DEBUG_NOTICE,("CTDB starting on node\n")); - gettimeofday(&ctdb->ctdbd_start_time, NULL); - gettimeofday(&ctdb->last_recovery_started, NULL); - gettimeofday(&ctdb->last_recovery_finished, NULL); - ctdb->recovery_mode = CTDB_RECOVERY_NORMAL; - ctdb->recovery_master = (uint32_t)-1; - ctdb->upcalls = &ctdb_upcalls; - if (options.recovery_lock == NULL) { DEBUG(DEBUG_WARNING, ("Recovery lock not set\n")); } @@ -280,7 +298,6 @@ int main(int argc, const char *argv[]) } /* set ctdbd capabilities */ - ctdb->capabilities = CTDB_CAP_DEFAULT; if (options.no_lmaster != 0) { ctdb->capabilities &= ~CTDB_CAP_LMASTER; } @@ -288,16 +305,6 @@ int main(int argc, const char *argv[]) ctdb->capabilities &= ~CTDB_CAP_RECMASTER; } - /* Initialise this node's PNN to the unknown value. This will - * be set to the correct value by either ctdb_add_node() as - * part of loading the nodes file or by - * ctdb_tcp_listen_automatic() when the transport is - * initialised. At some point we should de-optimise this and - * pull it out into ctdb_start_daemon() so it is done clearly - * and only in one place. - */ - ctdb->pnn = -1; - /* Default value for CTDB_BASE - don't override */ setenv("CTDB_BASE", CTDB_ETCDIR, 0); ctdb_base = getenv("CTDB_BASE"); @@ -341,8 +348,6 @@ int main(int argc, const char *argv[]) ctdb->do_setsched = (options.nosetsched != 1); - ctdb->do_checkpublicip = true; - t = getenv("CTDB_TEST_MODE"); if (t != NULL) { ctdb->do_setsched = false; -- 2.47.2