Fix large_dalloc_impl() to always lock large_mtx.

This commit is contained in:
Jason Evans 2016-09-23 12:16:55 -07:00
parent fd96974040
commit e3187ec6b6

View File

@ -281,18 +281,21 @@ large_ralloc(tsdn_t *tsdn, arena_t *arena, extent_t *extent, size_t usize,
return (ret); return (ret);
} }
/*
* junked_locked indicates whether the extent's data have been junk-filled, and
* whether the arena's lock is currently held. The arena's large_mtx is
* independent of these considerations.
*/
static void static void
large_dalloc_impl(tsdn_t *tsdn, extent_t *extent, bool junked_locked) large_dalloc_impl(tsdn_t *tsdn, extent_t *extent, bool junked_locked)
{ {
arena_t *arena; arena_t *arena;
arena = extent_arena_get(extent); arena = extent_arena_get(extent);
if (!junked_locked) malloc_mutex_lock(tsdn, &arena->large_mtx);
malloc_mutex_lock(tsdn, &arena->large_mtx);
ql_remove(&arena->large, extent, ql_link); ql_remove(&arena->large, extent, ql_link);
malloc_mutex_unlock(tsdn, &arena->large_mtx);
if (!junked_locked) { if (!junked_locked) {
malloc_mutex_unlock(tsdn, &arena->large_mtx);
large_dalloc_maybe_junk(tsdn, extent_addr_get(extent), large_dalloc_maybe_junk(tsdn, extent_addr_get(extent),
extent_usize_get(extent)); extent_usize_get(extent));
} }