summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorEmilio G. Cota <cota@braap.org>2015-08-23 20:23:40 -0400
committerPaolo Bonzini <pbonzini@redhat.com>2015-09-02 23:03:03 +0200
commit16ef9d0252318d7e32e445fd7474af55dbaab7db (patch)
tree98bd1fae33adb1e0ee30df37b4ca4ea1e15c464a
parent090d0bfd948343d522cd20bc634105b5cfe2483b (diff)
downloadfocaccia-qemu-16ef9d0252318d7e32e445fd7474af55dbaab7db.tar.gz
focaccia-qemu-16ef9d0252318d7e32e445fd7474af55dbaab7db.zip
qemu-thread: handle spurious futex_wait wakeups
Signed-off-by: Emilio G. Cota <cota@braap.org>
Message-Id: <1440375847-17603-12-git-send-email-cota@braap.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--util/qemu-thread-posix.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/util/qemu-thread-posix.c b/util/qemu-thread-posix.c
index ba67cec62b..d529405f53 100644
--- a/util/qemu-thread-posix.c
+++ b/util/qemu-thread-posix.c
@@ -298,7 +298,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)