rework langinfo code for ABI compat and for use by time code
[musl] / src / thread / pthread_detach.c
index 8ef03d5..651c38e 100644 (file)
@@ -3,9 +3,9 @@
 int pthread_detach(pthread_t t)
 {
        /* Cannot detach a thread that's already exiting */
-       if (a_swap(&t->exitlock, 1))
+       if (a_swap(t->exitlock, 1))
                return pthread_join(t, 0);
-       t->detached = 1;
-       t->exitlock = 0;
+       t->detached = 2;
+       __unlock(t->exitlock);
        return 0;
 }