Add internal tsd for background_thread.
This commit is contained in:
@@ -316,12 +316,11 @@ background_thread_entry(void *ind_arg) {
|
||||
set_current_thread_affinity((int)thread_ind);
|
||||
}
|
||||
/*
|
||||
* Start periodic background work. We avoid fetching tsd to keep the
|
||||
* background thread "outside", since there may be side effects, for
|
||||
* example triggering new arena creation (which in turn triggers
|
||||
* background thread creation).
|
||||
* Start periodic background work. We use internal tsd which avoids
|
||||
* side effects, for example triggering new arena creation (which in
|
||||
* turn triggers another background thread creation).
|
||||
*/
|
||||
background_work(TSDN_NULL, thread_ind);
|
||||
background_work(tsd_tsdn(tsd_internal_fetch()), thread_ind);
|
||||
assert(pthread_equal(pthread_self(),
|
||||
background_thread_info[thread_ind].thread));
|
||||
|
||||
|
11
src/tsd.c
11
src/tsd.c
@@ -103,7 +103,16 @@ tsd_data_init_nocleanup(tsd_t *tsd) {
|
||||
}
|
||||
|
||||
tsd_t *
|
||||
tsd_fetch_slow(tsd_t *tsd) {
|
||||
tsd_fetch_slow(tsd_t *tsd, bool internal) {
|
||||
if (internal) {
|
||||
/* For internal background threads use only. */
|
||||
assert(tsd->state == tsd_state_uninitialized);
|
||||
tsd->state = tsd_state_reincarnated;
|
||||
tsd_set(tsd);
|
||||
tsd_data_init_nocleanup(tsd);
|
||||
return tsd;
|
||||
}
|
||||
|
||||
if (tsd->state == tsd_state_nominal_slow) {
|
||||
/* On slow path but no work needed. */
|
||||
assert(malloc_slow || !tsd_tcache_enabled_get(tsd) ||
|
||||
|
Reference in New Issue
Block a user