Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2019-03-08 14:51:10 +0300
committerCorinna Vinschen <corinna@vinschen.de>2019-03-08 14:57:42 +0300
commit4ec5ffc198fcdcbea2dbca81a337900ac33b1fa7 (patch)
tree97d0ec123459c8c84dc480520bcbd0cc5a25b0b2 /winsup/cygwin/posix_timer.cc
parent094a2a17ad1cd65909fa2eee648d049d8d69fc45 (diff)
Cygwin: posix timers: fix a deadlockcygwin-3_0_3-release
Canceling the timer thread runs under lock. The thread uses the same lock to guard its timer_tracker struct access. If the timing is bad, timer_settime or timer_delete grab the lock at the same time, the timer expires. In the end, cancel waits for the thread sync while the thread waits for ther lock to be released. Fix this by not waiting for the thread sync under lock. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Diffstat (limited to 'winsup/cygwin/posix_timer.cc')
-rw-r--r--winsup/cygwin/posix_timer.cc2
1 files changed, 2 insertions, 0 deletions
diff --git a/winsup/cygwin/posix_timer.cc b/winsup/cygwin/posix_timer.cc
index a140b00e9..c0d548fe9 100644
--- a/winsup/cygwin/posix_timer.cc
+++ b/winsup/cygwin/posix_timer.cc
@@ -31,7 +31,9 @@ timer_tracker::cancel ()
SetEvent (cancel_evt);
if (sync_thr)
{
+ ReleaseSRWLockExclusive (&srwlock);
res = WaitForSingleObject (sync_thr, INFINITE);
+ AcquireSRWLockExclusive (&srwlock);
if (res != WAIT_OBJECT_0)
debug_printf ("WFSO returned unexpected value %u, %E", res);
}