diff options
-rw-r--r-- | htl/cancellation.c | 8 | ||||
-rw-r--r-- | htl/pt-self.c | 8 |
2 files changed, 15 insertions, 1 deletions
diff --git a/htl/cancellation.c b/htl/cancellation.c index a5d5d2a..7d38944 100644 --- a/htl/cancellation.c +++ b/htl/cancellation.c @@ -25,6 +25,10 @@ int __pthread_enable_asynccancel (void) struct __pthread *p = _pthread_self (); int oldtype; + if (___pthread_self == NULL) + /* We are not initialized yet, we can't be cancelled anyway. */ + return PTHREAD_CANCEL_DEFERRED; + __pthread_mutex_lock (&p->cancel_lock); oldtype = p->cancel_type; p->cancel_type = PTHREAD_CANCEL_ASYNCHRONOUS; @@ -39,6 +43,10 @@ void __pthread_disable_asynccancel (int oldtype) { struct __pthread *p = _pthread_self (); + if (___pthread_self == NULL) + /* We are not initialized yet, we can't be cancelled anyway. */ + return; + __pthread_mutex_lock (&p->cancel_lock); p->cancel_type = oldtype; __pthread_mutex_unlock (&p->cancel_lock); diff --git a/htl/pt-self.c b/htl/pt-self.c index 6fd3c98..e05ec69 100644 --- a/htl/pt-self.c +++ b/htl/pt-self.c @@ -24,7 +24,13 @@ pthread_t __pthread_self (void) { - struct __pthread *self = _pthread_self (); + struct __pthread *self; + + if (___pthread_self == NULL) + /* We are not initialized yet, we are the first thread. */ + return 1; + + self = _pthread_self (); assert (self != NULL); return self->thread; |