diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2018-05-08 21:36:41 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2018-05-08 21:37:48 +0300 |
commit | 510fb9f634b3374da6de7f6849e0a4f44f945723 (patch) | |
tree | eda01e794ce334acfd5d01aa76c437b7ff980684 /specific.c | |
parent | 228bb2776633790c562fa7f2d31c60978331036a (diff) | |
download | bdwgc-510fb9f634b3374da6de7f6849e0a4f44f945723.tar.gz |
Keep pointer to the start of previous entry in remove_specific_after_fork
(code refactoring)
* specific.c [USE_CUSTOM_SPECIFIC] (GC_remove_specific_after_fork):
Replace tse** link local variable with tse* prev one; replace *link
with either key->hash[hash_val].p or prev->next.
Diffstat (limited to 'specific.c')
-rw-r--r-- | specific.c | 14 |
1 files changed, 9 insertions, 5 deletions
@@ -81,7 +81,7 @@ GC_INNER void GC_remove_specific_after_fork(tsd * key, pthread_t t) { unsigned hash_val = HASH(t); tse *entry; - tse **link = &key->hash[hash_val].p; + tse *prev = NULL; # ifdef CAN_HANDLE_FORK /* Both GC_setspecific and GC_remove_specific should be called */ @@ -90,16 +90,20 @@ GC_INNER void GC_remove_specific_after_fork(tsd * key, pthread_t t) GC_ASSERT(I_HOLD_LOCK()); # endif pthread_mutex_lock(&(key -> lock)); - entry = *link; + entry = key->hash[hash_val].p; while (entry != NULL && !THREAD_EQUAL(entry->thread, t)) { - link = &(entry -> next); - entry = *link; + prev = entry; + entry = entry->next; } /* Invalidate qtid field, since qtids may be reused, and a later */ /* cache lookup could otherwise find this entry. */ if (entry != NULL) { entry -> qtid = INVALID_QTID; - *link = entry -> next; + if (NULL == prev) { + key->hash[hash_val].p = entry->next; + } else { + prev->next = entry->next; + } /* Atomic! concurrent accesses still work. */ /* They must, since readers don't lock. */ /* We shouldn't need a volatile access here, */ |