Synchronize arena->tcache_ql with arena->tcache_ql_mtx.

This replaces arena->lock synchronization.
This commit is contained in:
Jason Evans
2017-02-12 18:50:53 -08:00
parent 6b5cba4191
commit ab25d3c987
5 changed files with 31 additions and 21 deletions

View File

@@ -684,17 +684,12 @@ stats_print_atexit(void) {
if (arena != NULL) {
tcache_t *tcache;
/*
* tcache_stats_merge() locks bins, so if any
* code is introduced that acquires both arena
* and bin locks in the opposite order,
* deadlocks may result.
*/
malloc_mutex_lock(tsdn, &arena->lock);
malloc_mutex_lock(tsdn, &arena->tcache_ql_mtx);
ql_foreach(tcache, &arena->tcache_ql, link) {
tcache_stats_merge(tsdn, tcache, arena);
}
malloc_mutex_unlock(tsdn, &arena->lock);
malloc_mutex_unlock(tsdn,
&arena->tcache_ql_mtx);
}
}
}