aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--util/qemu-thread-posix.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/util/qemu-thread-posix.c b/util/qemu-thread-posix.c
index 8505d8c..ac1d56e 100644
--- a/util/qemu-thread-posix.c
+++ b/util/qemu-thread-posix.c
@@ -284,8 +284,12 @@ int qemu_sem_timedwait(QemuSemaphore *sem, int ms)
compute_abs_deadline(&ts, ms);
qemu_mutex_lock(&sem->mutex);
while (sem->count == 0) {
- rc = qemu_cond_timedwait_ts(&sem->cond, &sem->mutex, &ts,
- __FILE__, __LINE__);
+ if (ms == 0) {
+ rc = false;
+ } else {
+ rc = qemu_cond_timedwait_ts(&sem->cond, &sem->mutex, &ts,
+ __FILE__, __LINE__);
+ }
if (!rc) { /* timeout */
break;
}