mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-02-28 12:05:47 +08:00
* thread.h (class pthread): Add bool member canceled.
* thread.cc (pthread::pthread): Initialize canceled to false. (pthread::cancel): Set canceled before setting cancel_event. (pthread::testcancel): Check for canceled. Only wait for cancel_event if canceled is true. Explain why. (pthread::_fixup_after_fork): Set canceled to false.
This commit is contained in:
parent
e0b0b9e4ff
commit
42faed4128
@ -1,3 +1,12 @@
|
|||||||
|
2011-04-30 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
|
* thread.h (class pthread): Add bool member canceled.
|
||||||
|
* thread.cc (pthread::pthread): Initialize canceled to false.
|
||||||
|
(pthread::cancel): Set canceled before setting cancel_event.
|
||||||
|
(pthread::testcancel): Check for canceled. Only wait for cancel_event
|
||||||
|
if canceled is true. Explain why.
|
||||||
|
(pthread::_fixup_after_fork): Set canceled to false.
|
||||||
|
|
||||||
2011-04-29 Corinna Vinschen <corinna@vinschen.de>
|
2011-04-29 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
* errno.cc (errmap): Sort. Map ERROR_EXE_MACHINE_TYPE_MISMATCH to
|
* errno.cc (errmap): Sort. Map ERROR_EXE_MACHINE_TYPE_MISMATCH to
|
||||||
|
@ -378,7 +378,7 @@ List<pthread> pthread::threads;
|
|||||||
|
|
||||||
/* member methods */
|
/* member methods */
|
||||||
pthread::pthread ():verifyable_object (PTHREAD_MAGIC), win32_obj_id (0),
|
pthread::pthread ():verifyable_object (PTHREAD_MAGIC), win32_obj_id (0),
|
||||||
valid (false), suspended (false),
|
valid (false), suspended (false), canceled (false),
|
||||||
cancelstate (0), canceltype (0), cancel_event (0),
|
cancelstate (0), canceltype (0), cancel_event (0),
|
||||||
joiner (NULL), next (NULL), cleanup_stack (NULL)
|
joiner (NULL), next (NULL), cleanup_stack (NULL)
|
||||||
{
|
{
|
||||||
@ -538,6 +538,7 @@ pthread::cancel ()
|
|||||||
{
|
{
|
||||||
// cancel deferred
|
// cancel deferred
|
||||||
mutex.unlock ();
|
mutex.unlock ();
|
||||||
|
canceled = true;
|
||||||
SetEvent (cancel_event);
|
SetEvent (cancel_event);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -871,9 +872,17 @@ pthread::testcancel ()
|
|||||||
if (cancelstate == PTHREAD_CANCEL_DISABLE)
|
if (cancelstate == PTHREAD_CANCEL_DISABLE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (IsEventSignalled (cancel_event))
|
/* We check for the canceled flag first. This allows to use the
|
||||||
|
pthread_testcancel function a lot without adding the overhead of
|
||||||
|
an OS call. Only if the thread is marked as canceled, we wait for
|
||||||
|
cancel_event being really set, on the off-chance that pthread_cancel
|
||||||
|
gets interrupted before calling SetEvent. */
|
||||||
|
if (canceled)
|
||||||
|
{
|
||||||
|
WaitForSingleObject (cancel_event, INFINITE);
|
||||||
cancel_self ();
|
cancel_self ();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
pthread::static_cancel_self ()
|
pthread::static_cancel_self ()
|
||||||
@ -1039,6 +1048,7 @@ pthread::_fixup_after_fork ()
|
|||||||
magic = 0;
|
magic = 0;
|
||||||
valid = false;
|
valid = false;
|
||||||
win32_obj_id = NULL;
|
win32_obj_id = NULL;
|
||||||
|
canceled = false;
|
||||||
cancel_event = NULL;
|
cancel_event = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -366,6 +366,7 @@ public:
|
|||||||
void *return_ptr;
|
void *return_ptr;
|
||||||
bool valid;
|
bool valid;
|
||||||
bool suspended;
|
bool suspended;
|
||||||
|
bool canceled;
|
||||||
int cancelstate, canceltype;
|
int cancelstate, canceltype;
|
||||||
_cygtls *cygtls;
|
_cygtls *cygtls;
|
||||||
HANDLE cancel_event;
|
HANDLE cancel_event;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user