Fix lock ordering in `fat_mutex_lock' to match that of `do_thread_exit'.
[bpt/guile.git] / libguile / threads.c
index dba5d16..c07c853 100644 (file)
@@ -1371,6 +1371,8 @@ fat_mutex_lock (SCM mutex, scm_t_timespec *timeout, SCM owner, int *ret)
          if (SCM_I_IS_THREAD (new_owner))
            {
              scm_i_thread *t = SCM_I_THREAD_DATA (new_owner);
+
+             scm_i_pthread_mutex_unlock (&m->lock);
              scm_i_pthread_mutex_lock (&t->admin_mutex);
 
              /* Only keep a weak reference to MUTEX so that it's not
@@ -1381,6 +1383,7 @@ fat_mutex_lock (SCM mutex, scm_t_timespec *timeout, SCM owner, int *ret)
              t->mutexes = scm_weak_car_pair (mutex, t->mutexes);
 
              scm_i_pthread_mutex_unlock (&t->admin_mutex);
+             scm_i_pthread_mutex_lock (&m->lock);
            }
          *ret = 1;
          break;