cluster: RHEL56 - rgmanager: Fix stop/start race

Lon Hohberger lon at fedoraproject.org
Mon Feb 20 14:40:13 UTC 2012


Gitweb:        http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=36fd94d68003389d9585c87a649726742e06badd
Commit:        36fd94d68003389d9585c87a649726742e06badd
Parent:        737c05e726e32349dcf26fa1c54dabf4f94b6906
Author:        Lon Hohberger <lhh at redhat.com>
AuthorDate:    Mon Jun 15 14:18:36 2009 -0400
Committer:     Lon Hohberger <lhh at redhat.com>
CommitterDate: Mon Feb 20 09:39:42 2012 -0500

rgmanager: Fix stop/start race

If a thread exits right as rgmanager gets a request
to start a new thread, there's a chance that the
the starting thread will incorrectly have a reference
to the old thread and not retry when it should.

Resolves: rhbz#786525

Signed-off-by: Lon Hohberger <lhh at redhat.com>
---
 rgmanager/src/daemons/rg_thread.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/rgmanager/src/daemons/rg_thread.c b/rgmanager/src/daemons/rg_thread.c
index b89af97..769ca1e 100644
--- a/rgmanager/src/daemons/rg_thread.c
+++ b/rgmanager/src/daemons/rg_thread.c
@@ -620,6 +620,8 @@ spawn_if_needed(const char *resgroupname)
 	int ret;
 	resthread_t *resgroup = NULL;
 
+retry:
+	resgroup = NULL;
 	pthread_mutex_lock(&reslist_mutex);
 	while (resgroup == NULL) {
 		resgroup = find_resthread_byname(resgroupname);
@@ -637,8 +639,8 @@ spawn_if_needed(const char *resgroupname)
 	ret = (resgroup->rt_status == RG_STATE_STOPPING);
 
 	pthread_mutex_unlock(&reslist_mutex);
-	if (wait_initialize(resgroupname) < 0) {
-		return -1;
+	if (!ret && wait_initialize(resgroupname) < 0) {
+		goto retry;
 	}
 
 	return ret;


More information about the cluster-commits mailing list