semaphore: fix a hangup problem under load on NetBSD hosts.
authorIzumi Tsutsui <tsutsui@ceres.dti.ne.jp>
Wed, 3 Jul 2013 08:58:14 +0000 (17:58 +0900)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Mon, 26 Aug 2013 02:53:19 +0000 (11:53 +0900)
commit9e211a0b267b9f0decbfe4ddd8ea06185c811fca
treeb0859db77bc62a6a48c2e9abff9f9f63997e04e6
parentcecd7d0c75b57b2f0e63be0e95eb6cff663ef836
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()

Change-Id: Ic785784de211427cd3d0db746dbc1dbac3c8bc33
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>
include/qemu/thread-posix.h
util/qemu-thread-posix.c