1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-25 17:57:42 +03:00

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 <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
This commit is contained in:
Martin Schwenke 2021-07-09 14:01:33 +10:00 committed by Amitay Isaacs
parent e0a7b5a9e8
commit 1ac7bc7532
2 changed files with 26 additions and 3 deletions

View File

@ -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);

View File

@ -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? */