]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-daemon: Don't index by PNN when initialising node flags
authorMartin Schwenke <martin@meltin.net>
Fri, 21 Jun 2019 20:23:12 +0000 (06:23 +1000)
committerAmitay Isaacs <amitay@samba.org>
Fri, 5 Jul 2019 05:03:24 +0000 (05:03 +0000)
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 <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/server/ctdb_daemon.c

index e9fbc29cb98bacaae98fe8a1b2abb895a677a26e..c0553a18c140baf6931dacbdbdfaf649711bfe5f 100644 (file)
@@ -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;
        }
 }