From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17302 invoked by alias); 22 Jun 2009 13:34:05 -0000 Received: (qmail 17089 invoked by alias); 22 Jun 2009 13:34:02 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS X-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS X-Spam-Check-By: sourceware.org X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on bastion2.fedora.phx.redhat.com Subject: cluster: STABLE3 - rgmanager: Fix stop/start race To: cluster-cvs-relay@redhat.com X-Project: Cluster Project X-Git-Module: cluster.git X-Git-Refname: refs/heads/STABLE3 X-Git-Reftype: branch X-Git-Oldrev: 6a9c8dbb44439d57a9da92990619a1d47c081136 X-Git-Newrev: 3ad71b4ee6d277ff87d83683bb65f6d4cc69d905 From: Lon Hohberger Message-Id: <20090622133329.DECB612025B@lists.fedorahosted.org> Date: Mon, 22 Jun 2009 13:34:00 -0000 X-Scanned-By: MIMEDefang 2.58 on 172.16.52.254 Mailing-List: contact cluster-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: cluster-cvs-owner@sourceware.org X-SW-Source: 2009-q2/txt/msg00594.txt.bz2 Gitweb: http://git.fedorahosted.org/git/cluster.git?p=cluster.git;a=commitdiff;h=3ad71b4ee6d277ff87d83683bb65f6d4cc69d905 Commit: 3ad71b4ee6d277ff87d83683bb65f6d4cc69d905 Parent: 6a9c8dbb44439d57a9da92990619a1d47c081136 Author: Lon Hohberger AuthorDate: Mon Jun 15 14:18:36 2009 -0400 Committer: Lon Hohberger CommitterDate: Mon Jun 22 09:32:04 2009 -0400 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. Signed-off-by: Lon Hohberger --- 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 1aa64b3..5d22968 100644 --- a/rgmanager/src/daemons/rg_thread.c +++ b/rgmanager/src/daemons/rg_thread.c @@ -584,6 +584,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); @@ -601,8 +603,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;