X-Git-Url: http://nsz.repo.hu/git/?p=musl;a=blobdiff_plain;f=src%2Fthread%2Fpthread_create.c;h=52487001484ce8c1edfc08cd7b7027055c4a130d;hp=284b45a0f39c5639e8d7d4c0a1460d235c9e1983;hb=729cb49f52c825ac44f437e1ff0865d9f0b3626a;hpb=918a40f257328a2d7490829b54687cd38d7b787b diff --git a/src/thread/pthread_create.c b/src/thread/pthread_create.c index 284b45a0..52487001 100644 --- a/src/thread/pthread_create.c +++ b/src/thread/pthread_create.c @@ -57,9 +57,19 @@ static void cancel_handler(int sig, siginfo_t *si, void *ctx) static void cancelpt(int x) { struct pthread *self = __pthread_self(); - if (self->canceldisable) return; - if ((self->cancelpoint+=x)==1 && x>=0 && self->cancel) - docancel(self); + switch (x) { + case 1: + self->cancelpoint++; + case 0: + if (self->cancel && self->cancelpoint==1 && !self->canceldisable) + docancel(self); + break; + case -1: + self->cancelpoint--; + break; + default: + self->canceldisable += x; + } } /* "rsyscall" is a mechanism by which a thread can synchronously force all