1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-20 11:40:18 +02:00

make static hash table access thread-safe in foreign.c

* libguile/foreign.c (register_weak_reference): Wrap static hash table
  access in a mutex.
This commit is contained in:
Andy Wingo 2011-02-10 21:06:55 +01:00
parent c46345e69e
commit 05e7481311

View file

@ -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