ctdb-takeover: PNN can be used to index into node map
authorMartin Schwenke <martin@meltin.net>
Tue, 3 May 2016 02:46:16 +0000 (12:46 +1000)
committerAmitay Isaacs <amitay@samba.org>
Fri, 13 May 2016 11:47:16 +0000 (13:47 +0200)
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/server/ctdb_takeover.c

index 247d52ff035a1c24c1570eae2494df041c0c6f93..cf67278ab2c4333cf0bae4bc3ea97153d057ab9a 100644 (file)
@@ -1566,21 +1566,14 @@ static void takeover_run_fail_callback(struct ctdb_context *ctdb,
        struct takeover_callback_data *cd =
                talloc_get_type_abort(callback_data,
                                      struct takeover_callback_data);
-       int i;
-
-       for (i = 0; i < cd->nodemap->num; i++) {
-               if (node_pnn == cd->nodemap->nodes[i].pnn) {
-                       break;
-               }
-       }
 
-       if (i == cd->nodemap->num) {
+       if (node_pnn >= cd->nodemap->num) {
                DEBUG(DEBUG_ERR, (__location__ " invalid PNN %u\n", node_pnn));
                return;
        }
 
-       if (!cd->node_failed[i]) {
-               cd->node_failed[i] = true;
+       if (!cd->node_failed[node_pnn]) {
+               cd->node_failed[node_pnn] = true;
                cd->fail_callback(ctdb, node_pnn, res, outdata,
                                  cd->fail_callback_data);
        }