cluster: STABLE32 - cpglockd: fix a startup race condition

Ryan McCabe rmccabe at fedoraproject.org
Tue May 1 13:43:38 UTC 2012


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=237d91e9c292ae0e997f777934eb20c745369b4f
Commit:        237d91e9c292ae0e997f777934eb20c745369b4f
Parent:        dfc510ae98605633e86d27eec584c7768af70065
Author:        Fabio M. Di Nitto <fdinitto at redhat.com>
AuthorDate:    Tue Apr 24 12:07:25 2012 +0200
Committer:     Fabio M. Di Nitto <fdinitto at redhat.com>
CommitterDate: Tue Apr 24 17:04:09 2012 +0200

cpglockd: fix a startup race condition

[root at clusternet-node1 shm]# cpglockd -f
nodeid 1 already in group with PID 8126 8126
Unable to join CPG group

in some cases the cpg membership is updated between
cpglockd joining and cpglockd requesting current membership,
triggering the above error incorrectly.

check if the pids are the same, we can be rather sure
that it's us (given previous fix for startup pid/lock check)

Signed-off-by: Fabio M. Di Nitto <fdinitto at redhat.com>
---
 rgmanager/src/daemons/cpglockd.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/rgmanager/src/daemons/cpglockd.c b/rgmanager/src/daemons/cpglockd.c
index 5b6ea79..1bd53d3 100644
--- a/rgmanager/src/daemons/cpglockd.c
+++ b/rgmanager/src/daemons/cpglockd.c
@@ -1309,10 +1309,12 @@ cpg_init(void)
 
 	for (i = 0 ; i < cpg_member_list_len ; i++) {
 		if (member_list[i].nodeid == my_node_id) {
-			fprintf(stderr, "nodeid %d already in group with PID %u\n",
-				member_list[i].nodeid, member_list[i].pid);
-			cpg_fin();
-			return -1;
+			if (member_list[i].pid != getpid()) {
+				fprintf(stderr, "nodeid %d already in group with PID %u %u\n",
+					member_list[i].nodeid, member_list[i].pid, getpid());
+				cpg_fin();
+				return -1;
+			}
 		}
 	}
 


More information about the cluster-commits mailing list