ソースを参照

totemsrp: Fix srp_addr_compare

There is regression caused by "totem: Use nodeid ONLY in srp_addr" patch
in srp_addr_compare function. This function should be usable with qsort,
so it should return values less than, equal to or greater than zero. It
was however returning only zero or negation of a zero. Final results
were unable to reach consensus in following test case:
- 3 node cluster
- start nodes 1, 2, 3
- shutdown node 3
- start node 3
- shutdown node 2
- start node 2
- shutdown node 1

After this steps, node 2 and 3 were unable to reach consensus.

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
Jan Friesse 7 年 前
コミット
9b3782e48e
1 ファイル変更7 行追加1 行削除
  1. 7 1
      exec/totemsrp.c

+ 7 - 1
exec/totemsrp.c

@@ -3164,7 +3164,13 @@ static int srp_addr_compare (const void *a, const void *b)
 	const struct srp_addr *srp_a = (const struct srp_addr *)a;
 	const struct srp_addr *srp_b = (const struct srp_addr *)b;
 
-	return (srp_a->nodeid == srp_b->nodeid);
+	if (srp_a->nodeid < srp_b->nodeid) {
+		return -1;
+	} else if (srp_a->nodeid > srp_b->nodeid) {
+		return 1;
+	} else {
+		return 0;
+	}
 }
 
 static void memb_state_commit_token_create (