]> xenbits.xensource.com Git - people/pauldu/qemu.git/commitdiff
qemu-thread: handle spurious futex_wait wakeups
authorEmilio G. Cota <cota@braap.org>
Mon, 24 Aug 2015 00:23:40 +0000 (20:23 -0400)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 2 Sep 2015 21:03:03 +0000 (23:03 +0200)
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>
util/qemu-thread-posix.c

index ba67cec62bfcb9fc27e04ace2f6f274c39d713ad..d529405f53767cd854ec059c8eff6702d68a0d3f 100644 (file)
@@ -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)