فهرست منبع

cfgtool: Set nodeid indexes after sort

Needed for having correct index of localhost

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
Jan Friesse 4 سال پیش
والد
کامیت
d2d159a8ac
1فایلهای تغییر یافته به همراه14 افزوده شده و 8 حذف شده
  1. 14 8
      tools/corosync-cfgtool.c

+ 14 - 8
tools/corosync-cfgtool.c

@@ -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++) {