Patch from Olivier Coursiere (ticket #4064): cond_wait always return EAGAIN with an unitialized pthread_cond_t

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33779 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval 2009-10-26 19:28:14 +00:00
parent 857b0c2bef
commit 91844cc151

View File

@ -82,9 +82,11 @@ cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex, bigtime_t timeout)
// Note, this is thread-safe, since another thread would be required to
// hold the same mutex.
sem_id sem = create_sem(0, "pthread_cond");
if (cond->sem < 0)
if (sem < 0)
return EAGAIN;
cond->sem = sem;
if (atomic_test_and_set((vint32*)&cond->sem, sem, -42) != -42)
delete_sem(sem);
}
if (cond->mutex && cond->mutex != mutex)