diff options
author | Izumi Tsutsui <tsutsui@ceres.dti.ne.jp> | 2013-07-03 17:58:14 +0900 |
---|---|---|
committer | Anthony Liguori <aliguori@us.ibm.com> | 2013-08-05 11:48:00 -0500 |
commit | 79761c6681f0d1cc1c027116fcb4382d41ed3ece (patch) | |
tree | 9e2ac1f7b46d9a3d02b5cdfe545cfa45edafcc30 /include | |
parent | e1d0fb378ae3bb4272124a12e3fe1a02c4745eb1 (diff) |
semaphore: fix a hangup problem under load on NetBSD hosts.
Fix following bugs in "fallback implementation of counting semaphores
with mutex+condvar" added in c166cb72f1676855816340666c3b618beef4b976:
- waiting threads are not restarted properly if more than one threads
are waiting unblock signals in qemu_sem_timedwait()
- possible missing pthread_cond_signal(3) calls when waiting threads
are returned by ETIMEDOUT
- fix an uninitialized variable
The problem is analyzed by and fix is provided by Noriyuki Soda.
Also put additional cleanup suggested by Laszlo Ersek:
- make QemuSemaphore.count unsigned (it won't be negative)
- check a return value of in pthread_cond_wait() in qemu_sem_wait()
Signed-off-by: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Message-id: 1372841894-10634-1-git-send-email-tsutsui@ceres.dti.ne.jp
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/qemu/thread-posix.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/include/qemu/thread-posix.h b/include/qemu/thread-posix.h index 0f30dccb53..361566abc4 100644 --- a/include/qemu/thread-posix.h +++ b/include/qemu/thread-posix.h @@ -15,7 +15,7 @@ struct QemuSemaphore { #if defined(__APPLE__) || defined(__NetBSD__) pthread_mutex_t lock; pthread_cond_t cond; - int count; + unsigned int count; #else sem_t sem; #endif |