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
path: root/winsup
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2012-05-22 14:28:05 +0400
committerCorinna Vinschen <corinna@vinschen.de>2012-05-22 14:28:05 +0400
commit601431090344d2db08f9f19b30a8affb05a7ce0c (patch)
tree7e0c24b4ea169fa4f2a07148251da2476526950b /winsup
parent08d7e0c909744035300379edcc3e74d0184b3e30 (diff)
* thread.cc (pthread::cancel): Set thread's cancel_event in
PTHREAD_CANCEL_ASYNCHRONOUS case, too. Explain why.
Diffstat (limited to 'winsup')
-rw-r--r--winsup/cygwin/ChangeLog5
-rw-r--r--winsup/cygwin/thread.cc12
2 files changed, 17 insertions, 0 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 1b79569f8..263979b6a 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,8 @@
+2012-05-22 Corinna Vinschen <corinna@vinschen.de>
+
+ * thread.cc (pthread::cancel): Set thread's cancel_event in
+ PTHREAD_CANCEL_ASYNCHRONOUS case, too. Explain why.
+
2012-05-21 Corinna Vinschen <corinna@vinschen.de>
* strace.cc (strace::activate): Move printing heap size from here...
diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc
index 1bea526bf..f7ba60a70 100644
--- a/winsup/cygwin/thread.cc
+++ b/winsup/cygwin/thread.cc
@@ -566,6 +566,18 @@ pthread::cancel ()
SetThreadContext (win32_obj_id, &context);
}
mutex.unlock ();
+ /* Setting the context to another function does not work if the thread is
+ waiting in WFMO. For instance, a thread which waits for a semaphore in
+ sem_wait will call cancelable_wait which in turn calls WFMO. While this
+ WFMO call is cancelable by setting the thread's cancel_event object, the
+ OS apparently refuses to set the thread's context and continues to wait
+ for the WFMO conditions. This is *not* reflected in the return value of
+ SetThreadContext or ResumeThread, btw.
+ So, what we do here is to set the cancel_event as well. This allows the
+ WFMO call in cancelable_wait and elsewhere to return and to handle the
+ cancel request by itself. */
+ canceled = true;
+ SetEvent (cancel_event);
ResumeThread (win32_obj_id);
return 0;