summaryrefslogtreecommitdiff
path: root/libguile/foreign.c
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2011-02-10 21:06:55 +0100
committerAndy Wingo <wingo@pobox.com>2011-02-10 23:16:51 +0100
commit05e7481311957b8fdbc61275cac6584bdef061ca (patch)
tree4daf38967a94554955a41df1c36e1aedc9f8ca23 /libguile/foreign.c
parentc46345e69e862823629c0e108d907b5a9638fadc (diff)
downloadguile-05e7481311957b8fdbc61275cac6584bdef061ca.tar.gz
make static hash table access thread-safe in foreign.c
* libguile/foreign.c (register_weak_reference): Wrap static hash table access in a mutex.
Diffstat (limited to 'libguile/foreign.c')
-rw-r--r--libguile/foreign.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/libguile/foreign.c b/libguile/foreign.c
index c546c799a..6f008e761 100644
--- a/libguile/foreign.c
+++ b/libguile/foreign.c
@@ -30,6 +30,7 @@
#include "libguile/_scm.h"
#include "libguile/bytevectors.h"
#include "libguile/instructions.h"
+#include "libguile/threads.h"
#include "libguile/foreign.h"
@@ -86,11 +87,15 @@ static SCM cif_to_procedure (SCM cif, SCM func_ptr);
static SCM pointer_weak_refs = SCM_BOOL_F;
+static scm_i_pthread_mutex_t weak_refs_lock = SCM_I_PTHREAD_MUTEX_INITIALIZER;
+
static void
register_weak_reference (SCM from, SCM to)
{
+ scm_i_pthread_mutex_lock (&weak_refs_lock);
scm_hashq_set_x (pointer_weak_refs, from, to);
+ scm_i_pthread_mutex_unlock (&weak_refs_lock);
}
static void