summaryrefslogtreecommitdiff
path: root/specific.c
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2012-04-29 17:39:20 +0400
committerIvan Maidanski <ivmai@mail.ru>2012-04-29 17:39:20 +0400
commitea69b0893025fef6592c3aa736b3626fd109964f (patch)
tree9340f1b734d1aaae18e888aa6ef65cf8518653f4 /specific.c
parent9b4fe3946ae24f0f0e7b826c552564c482d17263 (diff)
parent596946199b9fea41770d8775e23c9de6e02f1ee7 (diff)
downloadbdwgc-ea69b0893025fef6592c3aa736b3626fd109964f.tar.gz
Merge branch 'fix-freelist-check-and-specific'
Diffstat (limited to 'specific.c')
-rw-r--r--specific.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/specific.c b/specific.c
index e35c9b57..20c78ade 100644
--- a/specific.c
+++ b/specific.c
@@ -44,14 +44,19 @@ GC_INNER int GC_key_create_inner(tsd ** key_ptr)
return 0;
}
+/* Called with the lock held. */
GC_INNER int GC_setspecific(tsd * key, void * value)
{
pthread_t self = pthread_self();
int hash_val = HASH(self);
- volatile tse * entry = (volatile tse *)MALLOC_CLEAR(sizeof (tse));
+ volatile tse * entry;
GC_ASSERT(self != INVALID_THREADID);
+ GC_dont_gc++; /* disable GC */
+ entry = (volatile tse *)MALLOC_CLEAR(sizeof(tse));
+ GC_dont_gc--;
if (0 == entry) return ENOMEM;
+
pthread_mutex_lock(&(key -> lock));
/* Could easily check for an existing entry here. */
entry -> next = key->hash[hash_val].p;