summaryrefslogtreecommitdiff
path: root/cancel.c
diff options
context:
space:
mode:
authorrpj <rpj>2000-09-07 15:41:11 +0000
committerrpj <rpj>2000-09-07 15:41:11 +0000
commit199d96f3e3f6077235be8e0bf9482d2a46e108c2 (patch)
treeebc172293f31102bb6441d68d29b94519a17984d /cancel.c
parent69b6d50683fcf0a7241953fdd2df6413477a2475 (diff)
2000-09-08 Ross Johnson <rpj@special.ise.canberra.edu.au>
* cancel.c (pthread_cancel): Must get "self" through calling pthread_self() which will ensure a POSIX thread struct is built for non-POSIX threads; return an error if this fails - Ollie Leahy <ollie@mpt.ie> (pthread_setcancelstate): Likewise. (pthread_setcanceltype): Likewise. * misc.c (ptw32_cancelable_wait): Likewise. * private.c (ptw32_tkAssocCreate): Remove unused #if 0 wrapped code. * pthread.h (ptw32_get_exception_services_code): Needed to be forward declared unconditionally. 2000-09-06 Ross Johnson <rpj@special.ise.canberra.edu.au> * cancel.c (pthread_cancel): If called from the main thread "self" would be NULL; get "self" via pthread_self() instead of directly from TLS so that an implicit pthread object is created. * misc.c (pthread_equal): Strengthen test for NULLs.
Diffstat (limited to 'cancel.c')
-rw-r--r--cancel.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/cancel.c b/cancel.c
index 9e5b789..2e8aa41 100644
--- a/cancel.c
+++ b/cancel.c
@@ -106,7 +106,7 @@ pthread_setcancelstate (int state, int *oldstate)
*/
{
int result = 0;
- pthread_t self = (pthread_t) pthread_getspecific (ptw32_selfThreadKey);
+ pthread_t self = pthread_self();
if (self == NULL
|| (state != PTHREAD_CANCEL_ENABLE
@@ -190,7 +190,7 @@ pthread_setcanceltype (int type, int *oldtype)
*/
{
int result = 0;
- pthread_t self = (pthread_t) pthread_getspecific (ptw32_selfThreadKey);
+ pthread_t self = pthread_self();
if (self == NULL
|| (type != PTHREAD_CANCEL_DEFERRED
@@ -261,7 +261,7 @@ pthread_testcancel (void)
* ------------------------------------------------------
*/
{
- pthread_t self = (pthread_t) pthread_getspecific (ptw32_selfThreadKey);
+ pthread_t self = pthread_self();
if (self != NULL
&& self->cancelState == PTHREAD_CANCEL_ENABLE
@@ -295,7 +295,7 @@ pthread_cancel (pthread_t thread)
* RESULTS
* 0 successfully requested cancellation,
* ESRCH no thread found corresponding to 'thread',
- *
+ * ENOMEM implicit self thread create failed.
* ------------------------------------------------------
*/
{
@@ -309,7 +309,10 @@ pthread_cancel (pthread_t thread)
}
result = 0;
- self = (pthread_t) pthread_getspecific (ptw32_selfThreadKey);
+ if ((self = pthread_self()) == NULL)
+ {
+ return ENOMEM;
+ };
/*
* FIXME!!