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

Function malloc_mutex_init

deps/jemalloc/src/mutex.c:134–182  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

132}
133
134bool
135malloc_mutex_init(malloc_mutex_t *mutex, const char *name,
136 witness_rank_t rank, malloc_mutex_lock_order_t lock_order) {
137 mutex_prof_data_init(&mutex->prof_data);
138#ifdef _WIN32
139# if _WIN32_WINNT >= 0x0600
140 InitializeSRWLock(&mutex->lock);
141# else
142 if (!InitializeCriticalSectionAndSpinCount(&mutex->lock,
143 _CRT_SPINCOUNT)) {
144 return true;
145 }
146# endif
147#elif (defined(JEMALLOC_OS_UNFAIR_LOCK))
148 mutex->lock = OS_UNFAIR_LOCK_INIT;
149#elif (defined(JEMALLOC_MUTEX_INIT_CB))
150 if (postpone_init) {
151 mutex->postponed_next = postponed_mutexes;
152 postponed_mutexes = mutex;
153 } else {
154 if (_pthread_mutex_init_calloc_cb(&mutex->lock,
155 bootstrap_calloc) != 0) {
156 return true;
157 }
158 }
159#else
160 pthread_mutexattr_t attr;
161
162 if (pthread_mutexattr_init(&attr) != 0) {
163 return true;
164 }
165 pthread_mutexattr_settype(&attr, MALLOC_MUTEX_TYPE);
166 if (pthread_mutex_init(&mutex->lock, &attr) != 0) {
167 pthread_mutexattr_destroy(&attr);
168 return true;
169 }
170 pthread_mutexattr_destroy(&attr);
171#endif
172 if (config_debug) {
173 mutex->lock_order = lock_order;
174 if (lock_order == malloc_mutex_address_ordered) {
175 witness_init(&mutex->witness, name, rank,
176 mutex_addr_comp, mutex);
177 } else {
178 witness_init(&mutex->witness, name, rank, NULL, NULL);
179 }
180 }
181 return false;
182}
183
184void
185malloc_mutex_prefork(tsdn_t *tsdn, malloc_mutex_t *mutex) {

Callers 15

bin_initFunction · 0.70
extents_initFunction · 0.70
malloc_tsd_boot0Function · 0.70
_init_init_lockFunction · 0.70
ctl_bootFunction · 0.70
prof_accum_initFunction · 0.70
prof_boot2Function · 0.70
mutex_pool_initFunction · 0.70
background_thread_boot1Function · 0.70
rtree_newFunction · 0.70

Calls 2

mutex_prof_data_initFunction · 0.70
witness_initFunction · 0.70

Tested by

no test coverage detected