fix potential deadlock in dlerror buffer handling at thread exit
[musl] / src / thread / pthread_spin_lock.c
index 0ab3d64..ded2b65 100644 (file)
@@ -1,7 +1,8 @@
 #include "pthread_impl.h"
+#include <errno.h>
 
 int pthread_spin_lock(pthread_spinlock_t *s)
 {
-       while (a_xchg(s, 1)) a_spin();
+       while (*(volatile int *)s || a_cas(s, 0, EBUSY)) a_spin();
        return 0;
 }