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>
This commit is contained in:
Emilio G. Cota 2015-08-23 20:23:40 -04:00 committed by Paolo Bonzini
parent 090d0bfd94
commit 16ef9d0252

View 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)