* 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>
|
||||
|
||||
* errno.cc (errmap): Sort. Map ERROR_EXE_MACHINE_TYPE_MISMATCH to
|
||||
|
|
|
@ -378,7 +378,7 @@ List<pthread> pthread::threads;
|
|||
|
||||
/* member methods */
|
||||
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),
|
||||
joiner (NULL), next (NULL), cleanup_stack (NULL)
|
||||
{
|
||||
|
@ -538,6 +538,7 @@ pthread::cancel ()
|
|||
{
|
||||
// cancel deferred
|
||||
mutex.unlock ();
|
||||
canceled = true;
|
||||
SetEvent (cancel_event);
|
||||
return 0;
|
||||
}
|
||||
|
@ -871,8 +872,16 @@ pthread::testcancel ()
|
|||
if (cancelstate == PTHREAD_CANCEL_DISABLE)
|
||||
return;
|
||||
|
||||
if (IsEventSignalled (cancel_event))
|
||||
cancel_self ();
|
||||
/* 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 ();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -1039,6 +1048,7 @@ pthread::_fixup_after_fork ()
|
|||
magic = 0;
|
||||
valid = false;
|
||||
win32_obj_id = NULL;
|
||||
canceled = false;
|
||||
cancel_event = NULL;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -366,6 +366,7 @@ public:
|
|||
void *return_ptr;
|
||||
bool valid;
|
||||
bool suspended;
|
||||
bool canceled;
|
||||
int cancelstate, canceltype;
|
||||
_cygtls *cygtls;
|
||||
HANDLE cancel_event;
|
||||
|
|
Loading…
Reference in New Issue