pthread_cond_broadcast is not asynch signal safe
[sbcl.git] / src / runtime / thread.h
index 249d226..e62cb2b 100644 (file)
@@ -30,28 +30,37 @@ static inline lispobj
 thread_state(struct thread *thread)
 {
     lispobj state;
+    sigset_t old;
+    block_blockable_signals(0, &old);
     pthread_mutex_lock(thread->state_lock);
     state = thread->state;
     pthread_mutex_unlock(thread->state_lock);
+    thread_sigmask(SIG_SETMASK,&old,0);
     return state;
 }
 
 static inline void
 set_thread_state(struct thread *thread, lispobj state)
 {
+    sigset_t old;
+    block_blockable_signals(0, &old);
     pthread_mutex_lock(thread->state_lock);
     thread->state = state;
     pthread_cond_broadcast(thread->state_cond);
     pthread_mutex_unlock(thread->state_lock);
+    thread_sigmask(SIG_SETMASK,&old,0);
 }
 
 static inline void
 wait_for_thread_state_change(struct thread *thread, lispobj state)
 {
+    sigset_t old;
+    block_blockable_signals(0, &old);
     pthread_mutex_lock(thread->state_lock);
     while (thread->state == state)
         pthread_cond_wait(thread->state_cond, thread->state_lock);
     pthread_mutex_unlock(thread->state_lock);
+    thread_sigmask(SIG_SETMASK,&old,0);
 }
 
 extern pthread_key_t lisp_thread;