From mboxrd@z Thu Jan 1 00:00:00 1970 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 Message-ID: <5090E55F.3090401@redhat.com> Date: Wed, 31 Oct 2012 09:46:23 +0100 From: Paolo Bonzini MIME-Version: 1.0 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> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 18/25] qemu-thread: add QemuSemaphore List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: aliguori@us.ibm.com, qemu-devel@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: 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__); } Paolo