[patch]cond_wait always return EAGAIN with an unitialized pthread_cond_t (pthread_cond.c)
|Reported by:||oco||Owned by:||axeld|
cond_wait always return EAGAIN with an unitialized pthread_cond_t (pthread_cond.c).
This function is used by pthread_cond_wait and pthread_cond_timedwait.
I discover the problem while trying to compile current ruby trunk (1.9). miniruby (a reduced version of ruby used in the build process) stop while calling pthread_cond_timedwait. The return value is always EAGAIN. I use hrev31395 of haiku.
After looking at the source code, i think we should check the return value of create_sem instead of cond->sem. This is what is in the first patch.
I found similar code in mutex_lock (pthread_mutex.c). Maybe, we should also use atomic_test_and_set to assign cond->sem. This is what is added in the second patch. But, as i am not sure of what i am proposing (i am a newbie with threads), careful revue is needed.