fixes for hanging waiting_thread-t.c on windows

mysys/my_wincond.c:
  race condition: block gate could be left open forever, if cond_broadcast
  was done right after the last thread left WaitForMultipleObjects() on timeout
mysys/thr_rwlock.c:
  make rwlocks behave similar to their distant linux/solaris relatives
This commit is contained in:
Sergei Golubchik
2008-10-21 16:10:04 +02:00
parent ade71b2522
commit c6a51b0447
2 changed files with 3 additions and 3 deletions

View File

@ -126,7 +126,7 @@ int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
EnterCriticalSection(&cond->lock_waiting);
cond->waiting--;
if (cond->waiting == 0 && result == (WAIT_OBJECT_0+BROADCAST))
if (cond->waiting == 0)
{
/*
We're the last waiter to be notified or to stop waiting, so

View File

@ -89,7 +89,7 @@ int my_rw_rdlock(rw_lock_t *rwp)
pthread_mutex_lock(&rwp->lock);
/* active or queued writers */
while (( rwp->state < 0 ) || rwp->waiters)
while (( rwp->state < 0 ))
pthread_cond_wait( &rwp->readers, &rwp->lock);
rwp->state++;
@ -101,7 +101,7 @@ int my_rw_tryrdlock(rw_lock_t *rwp)
{
int res;
pthread_mutex_lock(&rwp->lock);
if ((rwp->state < 0 ) || rwp->waiters)
if ((rwp->state < 0 ))
res= EBUSY; /* Can't get lock */
else
{