X-Git-Url: http://nsz.repo.hu/git/?p=musl;a=blobdiff_plain;f=src%2Fthread%2Fpthread_setcancelstate.c;h=ba2b231190436076b1d200bc76fa6e2c5dec9443;hp=aa0ddcdd316341ec0ab7a685e2e84a5a8a2b149b;hb=870cc679771f776333953b2a990a107393d9d0fd;hpb=9beb6330c08839e8bb2ebcd129c97c395d9d327e diff --git a/src/thread/pthread_setcancelstate.c b/src/thread/pthread_setcancelstate.c index aa0ddcdd..ba2b2311 100644 --- a/src/thread/pthread_setcancelstate.c +++ b/src/thread/pthread_setcancelstate.c @@ -2,9 +2,14 @@ int pthread_setcancelstate(int new, int *old) { - struct pthread *self = pthread_self(); - if (old) *old = self->canceldisable; if (new > 1U) return EINVAL; - self->canceldisable = new; + if (libc.main_thread) { + struct pthread *self = __pthread_self(); + if (old) *old = self->canceldisable; + self->canceldisable = new; + } else { + if (old) *old = libc.canceldisable; + libc.canceldisable = new; + } return 0; }