mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-02-21 00:07:36 +08:00
cygwin: pthread timed locks: actually timeout on timeout
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
parent
f378384804
commit
65c13851b3
@ -1432,13 +1432,21 @@ pthread_rwlock::rdlock (PLARGE_INTEGER timeout)
|
|||||||
|
|
||||||
while (writer || waiting_writers)
|
while (writer || waiting_writers)
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
pthread_cleanup_push (pthread_rwlock::rdlock_cleanup, this);
|
pthread_cleanup_push (pthread_rwlock::rdlock_cleanup, this);
|
||||||
|
|
||||||
++waiting_readers;
|
++waiting_readers;
|
||||||
cond_readers.wait (&mtx, timeout);
|
ret = cond_readers.wait (&mtx, timeout);
|
||||||
--waiting_readers;
|
--waiting_readers;
|
||||||
|
|
||||||
pthread_cleanup_pop (0);
|
pthread_cleanup_pop (0);
|
||||||
|
|
||||||
|
if (ret == ETIMEDOUT)
|
||||||
|
{
|
||||||
|
result = ETIMEDOUT;
|
||||||
|
goto DONE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((reader = add_reader ()))
|
if ((reader = add_reader ()))
|
||||||
@ -1496,13 +1504,21 @@ pthread_rwlock::wrlock (PLARGE_INTEGER timeout)
|
|||||||
|
|
||||||
while (writer || readers)
|
while (writer || readers)
|
||||||
{
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
pthread_cleanup_push (pthread_rwlock::wrlock_cleanup, this);
|
pthread_cleanup_push (pthread_rwlock::wrlock_cleanup, this);
|
||||||
|
|
||||||
++waiting_writers;
|
++waiting_writers;
|
||||||
cond_writers.wait (&mtx, timeout);
|
ret = cond_writers.wait (&mtx, timeout);
|
||||||
--waiting_writers;
|
--waiting_writers;
|
||||||
|
|
||||||
pthread_cleanup_pop (0);
|
pthread_cleanup_pop (0);
|
||||||
|
|
||||||
|
if (ret == ETIMEDOUT)
|
||||||
|
{
|
||||||
|
result = ETIMEDOUT;
|
||||||
|
goto DONE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
writer = self;
|
writer = self;
|
||||||
@ -1775,8 +1791,14 @@ pthread_mutex::lock (PLARGE_INTEGER timeout)
|
|||||||
else if (type == PTHREAD_MUTEX_NORMAL /* potentially causes deadlock */
|
else if (type == PTHREAD_MUTEX_NORMAL /* potentially causes deadlock */
|
||||||
|| !pthread::equal (owner, self))
|
|| !pthread::equal (owner, self))
|
||||||
{
|
{
|
||||||
cygwait (win32_obj_id, timeout, cw_sig | cw_sig_restart);
|
if (cygwait (win32_obj_id, timeout, cw_sig | cw_sig_restart)
|
||||||
set_owner (self);
|
!= WAIT_TIMEOUT)
|
||||||
|
set_owner (self);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
InterlockedDecrement (&lock_counter);
|
||||||
|
result = ETIMEDOUT;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user