From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32879) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZTfZ3-0006ux-Oh for qemu-devel@nongnu.org; Sun, 23 Aug 2015 20:24:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZTfZ0-0000g7-Uw for qemu-devel@nongnu.org; Sun, 23 Aug 2015 20:24:41 -0400 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:33769) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZTfZ0-0000g3-S0 for qemu-devel@nongnu.org; Sun, 23 Aug 2015 20:24:38 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id B99B520928 for ; Sun, 23 Aug 2015 20:24:38 -0400 (EDT) From: "Emilio G. Cota" Date: Sun, 23 Aug 2015 20:23:40 -0400 Message-Id: <1440375847-17603-12-git-send-email-cota@braap.org> In-Reply-To: <1440375847-17603-1-git-send-email-cota@braap.org> References: <1440375847-17603-1-git-send-email-cota@braap.org> Subject: [Qemu-devel] [RFC 11/38] qemu-thread: handle spurious futex_wait wakeups List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, mttcg@listserver.greensocs.com Cc: mark.burton@greensocs.com, a.rigo@virtualopensystems.com, guillaume.delbergue@greensocs.com, pbonzini@redhat.com, alex.bennee@linaro.org, Frederic Konrad Signed-off-by: Emilio G. Cota --- util/qemu-thread-posix.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/util/qemu-thread-posix.c b/util/qemu-thread-posix.c index 04dae0f..3760e27 100644 --- a/util/qemu-thread-posix.c +++ b/util/qemu-thread-posix.c @@ -303,7 +303,16 @@ static inline void futex_wake(QemuEvent *ev, int n) static inline void futex_wait(QemuEvent *ev, unsigned val) { - futex(ev, FUTEX_WAIT, (int) val, NULL, NULL, 0); + while (futex(ev, FUTEX_WAIT, (int) val, NULL, NULL, 0)) { + switch (errno) { + case EWOULDBLOCK: + return; + case EINTR: + break; /* get out of switch and retry */ + default: + abort(); + } + } } #else static inline void futex_wake(QemuEvent *ev, int n) -- 1.9.1