diff options
author | Andy Wingo <wingo@pobox.com> | 2011-02-10 21:06:55 +0100 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2011-02-10 23:16:51 +0100 |
commit | 05e7481311957b8fdbc61275cac6584bdef061ca (patch) | |
tree | 4daf38967a94554955a41df1c36e1aedc9f8ca23 /libguile/foreign.c | |
parent | c46345e69e862823629c0e108d907b5a9638fadc (diff) | |
download | guile-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.c | 5 |
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 |