From: Martin Schwenke Date: Fri, 9 Jul 2021 04:01:33 +0000 (+1000) Subject: ctdb-daemon: Factor out a function to get node structure from PNN X-Git-Tag: ldb-2.5.0~745 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1ac7bc7532b2fad791d0e53effa7c64cdc73c4eb;p=thirdparty%2Fsamba.git ctdb-daemon: Factor out a function to get node structure from PNN BUG: https://bugzilla.samba.org/show_bug.cgi?id=14784 Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h index 8eb6686f953..f5e647f08a5 100644 --- a/ctdb/include/ctdb_private.h +++ b/ctdb/include/ctdb_private.h @@ -565,6 +565,8 @@ int daemon_deregister_message_handler(struct ctdb_context *ctdb, void daemon_tunnel_handler(uint64_t tunnel_id, TDB_DATA data, void *private_data); +struct ctdb_node *ctdb_find_node(struct ctdb_context *ctdb, uint32_t pnn); + int ctdb_start_daemon(struct ctdb_context *ctdb, bool interactive, bool test_mode_enabled); diff --git a/ctdb/server/ctdb_daemon.c b/ctdb/server/ctdb_daemon.c index 3071e3cad54..e204bae73ad 100644 --- a/ctdb/server/ctdb_daemon.c +++ b/ctdb/server/ctdb_daemon.c @@ -1235,19 +1235,40 @@ failed: return -1; } -static void initialise_node_flags (struct ctdb_context *ctdb) +struct ctdb_node *ctdb_find_node(struct ctdb_context *ctdb, uint32_t pnn) { struct ctdb_node *node = NULL; unsigned int i; + if (pnn == CTDB_CURRENT_NODE) { + pnn = ctdb->pnn; + } + /* Always found: PNN correctly set just before this is called */ for (i = 0; i < ctdb->num_nodes; i++) { node = ctdb->nodes[i]; - if (ctdb->pnn == node->pnn) { - break; + if (pnn == node->pnn) { + return node; } } + return NULL; +} + +static void initialise_node_flags (struct ctdb_context *ctdb) +{ + struct ctdb_node *node = NULL; + + node = ctdb_find_node(ctdb, CTDB_CURRENT_NODE); + /* + * PNN correctly set just before this is called so always + * found but keep static analysers happy... + */ + if (node == NULL) { + DBG_ERR("Unable to find current node\n"); + return; + } + node->flags &= ~NODE_FLAGS_DISCONNECTED; /* do we start out in DISABLED mode? */