notify: loop while no signal is pending

pthread_cond_wait() may wake up spuriously.  To prevent superfluous
state checks, loop until the "pending" flag becomes true.  Removed the
dangerous assertion.
This commit is contained in:
Max Kellermann 2008-10-08 06:55:08 +02:00
parent 46eda29d1c
commit b42974eee1

View File

@ -43,9 +43,8 @@ void notify_deinit(struct notify *notify)
void notify_wait(struct notify *notify)
{
pthread_mutex_lock(&notify->mutex);
if (!notify->pending)
while (!notify->pending)
pthread_cond_wait(&notify->cond, &notify->mutex);
assert(notify->pending);
notify->pending = 0;
pthread_mutex_unlock(&notify->mutex);
}