summaryrefslogtreecommitdiff
path: root/libguile/threads.c
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2011-07-01 22:43:01 +0200
committerLudovic Courtès <ludo@gnu.org>2011-07-01 22:46:32 +0200
commit4f39f31ea58f08dfe22df8192e8ff02943a9ed5d (patch)
treea689b3af8def59b82911509b601d0bad01e3883c /libguile/threads.c
parent231c0e0e61fc4bdd69398e89084b7819f0420710 (diff)
downloadguile-4f39f31ea58f08dfe22df8192e8ff02943a9ed5d.tar.gz
Revert "Fix lock ordering in `fat_mutex_lock' to match that of `do_thread_exit'."
This reverts commit ccb80964cd7cd112e300c34d32f67125a6d6da9a, which introduced a race condition, with a small window during which a mutex could be held by a thread without being part of its `mutexes' list, thereby violating the invariant tested at line 667.
Diffstat (limited to 'libguile/threads.c')
-rw-r--r--libguile/threads.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/libguile/threads.c b/libguile/threads.c
index cbacfcad6..752354008 100644
--- a/libguile/threads.c
+++ b/libguile/threads.c
@@ -1370,7 +1370,9 @@ fat_mutex_lock (SCM mutex, scm_t_timespec *timeout, SCM owner, int *ret)
{
scm_i_thread *t = SCM_I_THREAD_DATA (new_owner);
- scm_i_pthread_mutex_unlock (&m->lock);
+ /* FIXME: The order in which `t->admin_mutex' and
+ `m->lock' are taken differs from that in
+ `on_thread_exit', potentially leading to deadlocks. */
scm_i_pthread_mutex_lock (&t->admin_mutex);
/* Only keep a weak reference to MUTEX so that it's not
@@ -1381,7 +1383,6 @@ 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;