about summary refs log tree commit diff
path: root/src/thread/pthread_setcancelstate.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/thread/pthread_setcancelstate.c')
-rw-r--r--src/thread/pthread_setcancelstate.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/thread/pthread_setcancelstate.c b/src/thread/pthread_setcancelstate.c
index aa0ddcdd..6722541a 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.lock) {
+		struct pthread *self = __pthread_self();
+		if (old) *old = self->canceldisable;
+		self->canceldisable = new;
+	} else {
+		if (old) *old = libc.canceldisable;
+		libc.canceldisable = new;
+	}
 	return 0;
 }