From: Martin Schwenke Date: Fri, 21 Jun 2019 20:23:12 +0000 (+1000) Subject: ctdb-daemon: Don't index by PNN when initialising node flags X-Git-Tag: samba-4.11.0rc1~48 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=75a808fd86a58371b465332f7c9d47d2dfbcbc08;p=thirdparty%2Fsamba.git ctdb-daemon: Don't index by PNN when initialising node flags Indexing by PNN is wrong. This also removes a signed/unsigned comparison because the PNN is not compared to -1 anymore. Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- diff --git a/ctdb/server/ctdb_daemon.c b/ctdb/server/ctdb_daemon.c index e9fbc29cb98..c0553a18c14 100644 --- a/ctdb/server/ctdb_daemon.c +++ b/ctdb/server/ctdb_daemon.c @@ -1229,23 +1229,26 @@ failed: static void initialise_node_flags (struct ctdb_context *ctdb) { - if (ctdb->pnn == -1) { - ctdb_fatal(ctdb, "PNN is set to -1 (unknown value)"); + unsigned int i; + + /* Always found: PNN correctly set just before this is called */ + for (i = 0; i < ctdb->num_nodes; i++) { + if (ctdb->pnn == ctdb->nodes[i]->pnn) { + break; + } } - ctdb->nodes[ctdb->pnn]->flags &= ~NODE_FLAGS_DISCONNECTED; + ctdb->nodes[i]->flags &= ~NODE_FLAGS_DISCONNECTED; /* do we start out in DISABLED mode? */ if (ctdb->start_as_disabled != 0) { - DEBUG(DEBUG_ERR, - ("This node is configured to start in DISABLED state\n")); - ctdb->nodes[ctdb->pnn]->flags |= NODE_FLAGS_DISABLED; + D_ERR("This node is configured to start in DISABLED state\n"); + ctdb->nodes[i]->flags |= NODE_FLAGS_DISABLED; } /* do we start out in STOPPED mode? */ if (ctdb->start_as_stopped != 0) { - DEBUG(DEBUG_ERR, - ("This node is configured to start in STOPPED state\n")); - ctdb->nodes[ctdb->pnn]->flags |= NODE_FLAGS_STOPPED; + D_ERR("This node is configured to start in STOPPED state\n"); + ctdb->nodes[i]->flags |= NODE_FLAGS_STOPPED; } }