In this case there is no need to call pthread_cond_timedwait; the function is just a trywait and waiting on the condition variable would always time out.
Based-on: <20220222090507.2028-1-longpe...@huawei.com> Cc: "Longpeng(Mike)" <longpe...@huawei.com> Signed-off-by: Paolo Bonzini <pbonz...@redhat.com> --- util/qemu-thread-posix.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/util/qemu-thread-posix.c b/util/qemu-thread-posix.c index f2ce47d36b..89c23f1d64 100644 --- a/util/qemu-thread-posix.c +++ b/util/qemu-thread-posix.c @@ -282,8 +282,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; } -- 2.34.1