From: Martin Schwenke Date: Wed, 18 Apr 2018 04:44:01 +0000 (+1000) Subject: ctdb-daemon: Consolidate basic CTDB context initialisation X-Git-Tag: ldb-1.4.0~480 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9623c920ab142a3d6dafaaad4086edab9eae63f5;p=thirdparty%2Fsamba.git 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 --- 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;