[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] cluster/cmirror-kernel/src dm-cmirror-client.c



CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL4
Changes by:	jbrassow sourceware org	2006-07-07 17:08:56

Modified files:
	cmirror-kernel/src: dm-cmirror-client.c 

Log message:
	- If a cluster mirror was removed, and a new one created fast enough, the
	processes could overlap such that the creation would fail to register
	with cman because the remove hadn't unregistered yet (-EEXIST)
	
	This should fix bug 197952
	
	Waiting to commit this to rhel4u4 until the bug becomes a blocker.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cmirror-kernel/src/dm-cmirror-client.c.diff?cvsroot=cluster&only_with_tag=RHEL4&r1=1.1.2.20&r2=1.1.2.21

--- cluster/cmirror-kernel/src/Attic/dm-cmirror-client.c	2006/06/29 19:48:01	1.1.2.20
+++ cluster/cmirror-kernel/src/Attic/dm-cmirror-client.c	2006/07/07 17:08:56	1.1.2.21
@@ -1206,26 +1206,31 @@
 };
 
 static int mirror_set_count = 0; /* used to prevent multiple cluster [dis]connects */
+static DECLARE_MUTEX(cmirror_register_lock);
 
 static int cluster_connect(void)
 {
-	int r;
+	int r = 0;
 
-	if (mirror_set_count++)
-		return 0;
+	down(&cmirror_register_lock);
+
+	if (mirror_set_count++) {
+		up(&cmirror_register_lock);
+		goto out;
+	}
 
 	r = kcl_register_service("clustered_log", 13, SERVICE_LEVEL_GDLM, &clog_ops,
 				 1, NULL, &local_id);
 	if (r) {
-		DMWARN("Couldn't register clustered_log service");
-		return r;
+		DMWARN("Couldn't register clustered_log service.  Reason: %d", r);
+		goto out;
 	}
 
 	r = start_server();
 	if(r){
 		DMWARN("Unable to start clustered log server daemon");
 		kcl_unregister_service(local_id);
-		return r;
+		goto out;
 	}
 
 	r = kcl_join_service(local_id);
@@ -1236,13 +1241,19 @@
 		kcl_unregister_service(local_id);
 	}
 
+out:
+	up(&cmirror_register_lock);
 	return r;
 }
 
 static int cluster_disconnect(void)
 {
-	if (--mirror_set_count)
+	down(&cmirror_register_lock);
+
+	if (--mirror_set_count) {
+		up(&cmirror_register_lock);
 		return 0;
+	}
 
 	/* By setting 'shutting_down', the server will not be suspended **
 	** when a stop is received */
@@ -1251,6 +1262,7 @@
 	stop_server();
 	kcl_unregister_service(local_id);
 
+	up(&cmirror_register_lock);
 	return 0;
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]