]> git.proxmox.com Git - mirror_corosync.git/commitdiff
cfgtool: Set nodeid indexes after sort
authorJan Friesse <jfriesse@redhat.com>
Mon, 2 Aug 2021 06:56:09 +0000 (08:56 +0200)
committerJan Friesse <jfriesse@redhat.com>
Mon, 2 Aug 2021 13:13:31 +0000 (15:13 +0200)
Needed for having correct index of localhost

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
tools/corosync-cfgtool.c

index e51311bbce67c48bb33ab8090350aace4e442320..5b9d856486933c11946721e23c07bd4201b36d66 100644 (file)
@@ -172,14 +172,6 @@ nodestatusget_do (enum user_action action, int brief)
                        continue;
                }
                if (cmap_get_uint32(cmap_handle, iter_key, &nodeid) == CS_OK) {
-                       if (nodeid == local_nodeid) {
-                               local_nodeid_index = s;
-                       } else {
-                               /* Bit of an odd one this. but local node only uses one link (of course, to itself)
-                                  so if we want to know which links are active across the cluster we need to look
-                                  at another node (any other) node's link list */
-                               other_nodeid_index = s;
-                       }
                        nodeid_list[s++] = nodeid;
                }
        }
@@ -192,6 +184,20 @@ nodestatusget_do (enum user_action action, int brief)
        /* It's nice to have these in nodeid order */
        qsort(nodeid_list, s, sizeof(uint32_t), node_compare);
 
+       /*
+        * Find local and other nodeid index in nodeid_list
+        */
+       for (i = 0; i < s; i++) {
+               if (nodeid_list[i] == local_nodeid) {
+                       local_nodeid_index = i;
+               } else {
+                       /* Bit of an odd one this. but local node only uses one link (of course, to itself)
+                          so if we want to know which links are active across the cluster we need to look
+                          at another node (any other) node's link list */
+                       other_nodeid_index = i;
+               }
+       }
+
        /* Get the transport of each link - but set reasonable defaults */
        if (transport_number == TOTEM_TRANSPORT_KNET) {
                for (i = 0; i<KNET_MAX_LINK; i++) {