MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / tsd_init_check_recursion

Function tsd_init_check_recursion

deps/jemalloc/src/tsd.c:487–506  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

485#if (!defined(JEMALLOC_MALLOC_THREAD_CLEANUP) && !defined(JEMALLOC_TLS) && \
486 !defined(_WIN32))
487void *
488tsd_init_check_recursion(tsd_init_head_t *head, tsd_init_block_t *block) {
489 pthread_t self = pthread_self();
490 tsd_init_block_t *iter;
491
492 /* Check whether this thread has already inserted into the list. */
493 malloc_mutex_lock(TSDN_NULL, &head->lock);
494 ql_foreach(iter, &head->blocks, link) {
495 if (iter->thread == self) {
496 malloc_mutex_unlock(TSDN_NULL, &head->lock);
497 return iter->data;
498 }
499 }
500 /* Insert block into list. */
501 ql_elm_new(block, link);
502 block->thread = self;
503 ql_tail_insert(&head->blocks, block, link);
504 malloc_mutex_unlock(TSDN_NULL, &head->lock);
505 return NULL;
506}
507
508void
509tsd_init_finish(tsd_init_head_t *head, tsd_init_block_t *block) {

Callers 1

tsd_generic.hFile · 0.50

Calls 3

malloc_mutex_lockFunction · 0.50
ql_foreachFunction · 0.50
malloc_mutex_unlockFunction · 0.50

Tested by

no test coverage detected