summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2016-11-13 12:43:46 +0100
committerAndy Wingo <wingo@pobox.com>2016-11-13 15:56:21 +0100
commit1ed9dea34aa8cb0cbae17200c31d1ac91a6a01de (patch)
tree76686e53cc23125f6575d459cde7f7034af8d08f
parent4110e7bbb181786059a9d2b6ff010a99f69e5710 (diff)
downloadguile-1ed9dea34aa8cb0cbae17200c31d1ac91a6a01de.tar.gz
Unlocked mutexes don't have owners
* libguile/threads.c (scm_unlock_mutex) (scm_timed_wait_condition_variable): Unlocked mutexes should never have owners.
-rw-r--r--libguile/threads.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/libguile/threads.c b/libguile/threads.c
index 1c8879644..863c84f71 100644
--- a/libguile/threads.c
+++ b/libguile/threads.c
@@ -1268,8 +1268,11 @@ SCM_DEFINE (scm_unlock_mutex, "unlock-mutex", 1, 0, 0, (SCM mutex),
if (m->level > 0)
m->level--;
if (m->level == 0)
- /* Change the owner of MUTEX. */
- m->owner = unblock_from_queue (m->waiting);
+ /* Wake up one waiter. */
+ {
+ m->owner = SCM_BOOL_F;
+ unblock_from_queue (m->waiting);
+ }
scm_i_pthread_mutex_unlock (&m->lock);
@@ -1414,8 +1417,11 @@ SCM_DEFINE (scm_timed_wait_condition_variable, "wait-condition-variable", 2, 1,
if (m->level > 0)
m->level--;
if (m->level == 0)
- /* Change the owner of MUTEX. */
- m->owner = unblock_from_queue (m->waiting);
+ {
+ m->owner = SCM_BOOL_F;
+ /* Wake up one waiter. */
+ unblock_from_queue (m->waiting);
+ }
t->block_asyncs++;