From patchwork Wed Oct 31 08:46:23 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 195771 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id F21472C00D7 for ; Wed, 31 Oct 2012 19:46:46 +1100 (EST) Received: from localhost ([::1]:48956 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TTTwj-0001ul-6i for incoming@patchwork.ozlabs.org; Wed, 31 Oct 2012 04:46:45 -0400 Received: from eggs.gnu.org ([208.118.235.92]:49232) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TTTwY-0001ub-M2 for qemu-devel@nongnu.org; Wed, 31 Oct 2012 04:46:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TTTwS-0004Uf-UB for qemu-devel@nongnu.org; Wed, 31 Oct 2012 04:46:34 -0400 Received: from mx1.redhat.com ([209.132.183.28]:25080) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TTTwS-0004Ua-Lm for qemu-devel@nongnu.org; Wed, 31 Oct 2012 04:46:28 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q9V8kRZ8012437 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 31 Oct 2012 04:46:27 -0400 Received: from yakj.usersys.redhat.com (ovpn-112-26.ams2.redhat.com [10.36.112.26]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q9V8kNlt008213; Wed, 31 Oct 2012 04:46:24 -0400 Message-ID: <5090E55F.3090401@redhat.com> Date: Wed, 31 Oct 2012 09:46:23 +0100 From: Paolo Bonzini User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121016 Thunderbird/16.0.1 MIME-Version: 1.0 To: Stefan Hajnoczi References: <1351260355-19802-1-git-send-email-pbonzini@redhat.com> <1351260355-19802-19-git-send-email-pbonzini@redhat.com> <20121030184858.GC16674@stefanha-thinkpad.redhat.com> In-Reply-To: <20121030184858.GC16674@stefanha-thinkpad.redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: aliguori@us.ibm.com, qemu-devel@nongnu.org Subject: Re: [Qemu-devel] [PATCH 18/25] qemu-thread: add QemuSemaphore X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Il 30/10/2012 19:48, Stefan Hajnoczi ha scritto: >> + if (rc < 0) { >> + error_exit(errno, __func__); >> + } > > Forgot to handle EINTR? > >> + return 0; >> +} >> + >> +void qemu_sem_wait(QemuSemaphore *sem) >> +{ >> + int rc; >> + >> + rc = sem_wait(&sem->sem); >> + if (rc < 0) { >> + error_exit(errno, __func__); >> + } > > EINTR Right! I'm squashing this: Paolo diff --git a/qemu-thread-posix.c b/qemu-thread-posix.c index dea57d4..6a3d3a1 100644 --- a/qemu-thread-posix.c +++ b/qemu-thread-posix.c @@ -154,7 +154,9 @@ int qemu_sem_timedwait(QemuSemaphore *sem, int ms) if (ms <= 0) { /* This is cheaper than sem_timedwait. */ - rc = sem_trywait(&sem->sem); + do { + rc = sem_trywait(&sem->sem); + } while (rc == -1 && errno == EINTR); if (rc == -1 && errno == EAGAIN) { return -1; } @@ -168,7 +170,9 @@ int qemu_sem_timedwait(QemuSemaphore *sem, int ms) ts.tv_sec++; ts.tv_nsec -= 1000000000; } - rc = sem_timedwait(&sem->sem, &ts); + do { + rc = sem_timedwait(&sem->sem, &ts); + } while (rc == -1 && errno == EINTR); if (rc == -1 && errno == ETIMEDOUT) { return -1; } @@ -183,7 +187,9 @@ void qemu_sem_wait(QemuSemaphore *sem) { int rc; - rc = sem_wait(&sem->sem); + do { + rc = sem_wait(&sem->sem); + } while (rc == -1 && errno == EINTR); if (rc < 0) { error_exit(errno, __func__); }