Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > media > main-src > by-pkgid > e536fc0c6270ec1d92a0fd41bb1f8360 > files > 79

rgmanager-2.0.52-28.el5_8.2.src.rpm

From 0f070b75b0864ed4b46c361916f822b4a57a1a3f Mon Sep 17 00:00:00 2001
From: Lon Hohberger <lhh@redhat.com>
Date: Mon, 15 Jun 2009 14:18:36 -0400
Subject: [PATCH] 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#752486

Signed-off-by: Lon Hohberger <lhh@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;
-- 
1.7.3.4