Cygwin: timerfd: avoid a deadlock

Add a function timerfd_tracker::enter_critical_section_cancelable,
which is like enter_critical_section but honors a cancel event.  Call
this when a timer expires while the timerfd thread is in its inner
loop.  This avoids a deadlock if timerfd_tracker::dtor has entered its
critical section and is trying to cancel the thread.  See
https://cygwin.com/ml/cygwin/2019-06/msg00096.html.
This commit is contained in:
Ken Brown
2019-06-24 12:28:48 -04:00
parent a90aa583fb
commit 9604a251bd
3 changed files with 28 additions and 1 deletions

View File

@@ -86,6 +86,8 @@ class timerfd_tracker /* cygheap! */
return (WaitForSingleObject (_access_mtx, INFINITE) & ~WAIT_ABANDONED_0)
== WAIT_OBJECT_0;
}
/* A version that honors a cancel event, for use in thread_func. */
int enter_critical_section_cancelable ();
void leave_critical_section ()
{
ReleaseMutex (_access_mtx);