projects
/
musl
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix race condition in pthread_kill
[musl]
/
src
/
thread
/
pthread_setcancelstate.c
diff --git
a/src/thread/pthread_setcancelstate.c
b/src/thread/pthread_setcancelstate.c
index
aa0ddcd
..
ba2b231
100644
(file)
--- a/
src/thread/pthread_setcancelstate.c
+++ b/
src/thread/pthread_setcancelstate.c
@@
-2,9
+2,14
@@
int pthread_setcancelstate(int new, int *old)
{
int pthread_setcancelstate(int new, int *old)
{
- struct pthread *self = pthread_self();
- if (old) *old = self->canceldisable;
if (new > 1U) return EINVAL;
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;
}
return 0;
}