linux-rt-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: John Kacur <jkacur@redhat.com>
Cc: rt-users <linux-rt-users@vger.kernel.org>,
	Clark Williams <williams@redhat.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Carsten Emde <C.Emde@osadl.org>
Subject: Re: [PATCH 2/6] Fix possible exit on error without releasing mutex
Date: Tue, 14 Jul 2015 17:59:59 +0200	[thread overview]
Message-ID: <20150714155959.GE21820@linutronix.de> (raw)
In-Reply-To: <1436531131-9186-3-git-send-email-jkacur@redhat.com>

* John Kacur | 2015-07-10 14:25:27 [+0200]:

>diff --git a/src/pi_tests/pi_stress.c b/src/pi_tests/pi_stress.c
>index aaa36c362445..1d1cc58fae54 100644
>--- a/src/pi_tests/pi_stress.c
>+++ b/src/pi_tests/pi_stress.c
>@@ -727,17 +727,24 @@ void *low_priority(void *arg)
> 		status = pthread_barrier_wait(&p->locked_barrier);
> 		if (status && status != PTHREAD_BARRIER_SERIAL_THREAD) {
> 			pi_error
>-			    ("low_priority[%d]: pthread_barrier_wait(locked): %x\n",
>-			     p->id, status);
>+				("low_priority[%d]: pthread_barrier_wait(locked): %x\n",
>+				 p->id, status);
>+			/* release the mutex */
>+			pi_debug("low_priority[%d]: unlocking mutex\n", p->id);
>+			pthread_mutex_unlock(&p->mutex);
> 			return NULL;
> 		}
>+
> 		/* wait for priority boost */
> 		pi_debug("low_priority[%d]: entering elevated wait\n", p->id);
> 		status = pthread_barrier_wait(&p->elevate_barrier);
> 		if (status && status != PTHREAD_BARRIER_SERIAL_THREAD) {
> 			pi_error
>-			    ("low_priority[%d]: pthread_barrier_wait(elevate): %x\n",
>-			     p->id, status);
>+				("low_priority[%d]: pthread_barrier_wait(elevate): %x\n",
>+				 p->id, status);
>+			/* release the mutex */
>+			pi_debug("low_priority[%d]: unlocking mutex\n", p->id);
>+			pthread_mutex_unlock(&p->mutex);
> 			return NULL;
> 		}
> 

What about having an out: label which does all the clean up at one spot
instead of doing copy/paste here and there?

Sebastian

  reply	other threads:[~2015-07-14 16:00 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-10 12:25 [PATCH 0/6] Various rt-test patches John Kacur
2015-07-10 12:25 ` [PATCH 1/6] Fix warning: unused variable ‘c’ John Kacur
2015-07-10 12:25 ` [PATCH 2/6] Fix possible exit on error without releasing mutex John Kacur
2015-07-14 15:59   ` Sebastian Andrzej Siewior [this message]
2015-07-14 21:03     ` John Kacur
2015-07-10 12:25 ` [PATCH 3/6] Create a .gitattribute file to specify what files git-archive should ignore John Kacur
2015-07-10 12:25 ` [PATCH 4/6] Add .tar files to .gitignore John Kacur
2015-07-14 15:58   ` Sebastian Andrzej Siewior
2015-07-14 20:33     ` John Kacur
2015-07-10 12:25 ` [PATCH 5/6] Change VERSION_STRING to VERSION John Kacur
2015-07-10 13:42   ` Pavel Vasilyev
2015-07-14 16:09   ` Sebastian Andrzej Siewior
2015-07-14 21:45     ` John Kacur
2015-07-10 12:25 ` [PATCH 6/6] Create an rt-tests.tar file using git-archive John Kacur
2015-07-14 16:13   ` Sebastian Andrzej Siewior
2015-07-14 20:28     ` John Kacur

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150714155959.GE21820@linutronix.de \
    --to=bigeasy@linutronix.de \
    --cc=C.Emde@osadl.org \
    --cc=jkacur@redhat.com \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=williams@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).