1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-08-08 17:42:12 +03:00
This commit is contained in:
Jakub Jelinek
2007-07-12 18:26:36 +00:00
parent 7d58530341
commit 0ecb606cb6
6215 changed files with 494638 additions and 305010 deletions

View File

@@ -44,15 +44,35 @@ __pthread_cond_destroy (cond)
broadcasted, but still are using the pthread_cond_t structure,
pthread_cond_destroy needs to wait for them. */
unsigned int nwaiters = cond->__data.__nwaiters;
while (nwaiters >= (1 << COND_CLOCK_BITS))
if (nwaiters >= (1 << COND_CLOCK_BITS))
{
lll_mutex_unlock (cond->__data.__lock);
/* Wake everybody on the associated mutex in case there are
threads that have been requeued to it.
Without this, pthread_cond_destroy could block potentially
for a long time or forever, as it would depend on other
thread's using the mutex.
When all threads waiting on the mutex are woken up, pthread_cond_wait
only waits for threads to acquire and release the internal
condvar lock. */
if (cond->__data.__mutex != NULL
&& cond->__data.__mutex != (void *) ~0l)
{
pthread_mutex_t *mut = (pthread_mutex_t *) cond->__data.__mutex;
lll_futex_wake (&mut->__data.__lock, INT_MAX);
}
lll_futex_wait (&cond->__data.__nwaiters, nwaiters);
do
{
lll_mutex_unlock (cond->__data.__lock);
lll_mutex_lock (cond->__data.__lock);
lll_futex_wait (&cond->__data.__nwaiters, nwaiters);
nwaiters = cond->__data.__nwaiters;
lll_mutex_lock (cond->__data.__lock);
nwaiters = cond->__data.__nwaiters;
}
while (nwaiters >= (1 << COND_CLOCK_BITS));
}
return 0;