Gitweb:
http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=...
Commit: 0f070b75b0864ed4b46c361916f822b4a57a1a3f
Parent: 169ba7b72909720363dffab9993b3f3f586e6ae6
Author: Lon Hohberger <lhh(a)redhat.com>
AuthorDate: Mon Jun 15 14:18:36 2009 -0400
Committer: Lon Hohberger <lhh(a)redhat.com>
CommitterDate: Wed Nov 9 12:33:49 2011 -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#752486
Signed-off-by: Lon Hohberger <lhh(a)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;