mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-07-24 13:53:11 +00:00
Fix tsd cleanup regressions.
Fix tsd cleanup regressions that were introduced in
5460aa6f66 (Convert all tsd variables to
reside in a single tsd structure.). These regressions were twofold:
1) tsd_tryget() should never (and need never) return NULL. Rename it to
tsd_fetch() and simplify all callers.
2) tsd_*_set() must only be called when tsd is in the nominal state,
because cleanup happens during the nominal-->purgatory transition,
and re-initialization must not happen while in the purgatory state.
Add tsd_nominal() and use it as needed. Note that tsd_*{p,}_get()
can still be used as long as no re-initialization that would require
cleanup occurs. This means that e.g. the thread_allocated counter
can be updated unconditionally.
This commit is contained in:
@@ -5,8 +5,7 @@ TEST_BEGIN(test_new_delete)
|
||||
tsd_t *tsd;
|
||||
ckh_t ckh;
|
||||
|
||||
tsd = tsd_tryget();
|
||||
assert_ptr_not_null(tsd, "Unexpected tsd failure");
|
||||
tsd = tsd_fetch();
|
||||
|
||||
assert_false(ckh_new(tsd, &ckh, 2, ckh_string_hash, ckh_string_keycomp),
|
||||
"Unexpected ckh_new() error");
|
||||
@@ -31,8 +30,7 @@ TEST_BEGIN(test_count_insert_search_remove)
|
||||
const char *missing = "A string not in the hash table.";
|
||||
size_t i;
|
||||
|
||||
tsd = tsd_tryget();
|
||||
assert_ptr_not_null(tsd, "Unexpected tsd failure");
|
||||
tsd = tsd_fetch();
|
||||
|
||||
assert_false(ckh_new(tsd, &ckh, 2, ckh_string_hash, ckh_string_keycomp),
|
||||
"Unexpected ckh_new() error");
|
||||
@@ -116,8 +114,7 @@ TEST_BEGIN(test_insert_iter_remove)
|
||||
void *q, *r;
|
||||
size_t i;
|
||||
|
||||
tsd = tsd_tryget();
|
||||
assert_ptr_not_null(tsd, "Unexpected tsd failure");
|
||||
tsd = tsd_fetch();
|
||||
|
||||
assert_false(ckh_new(tsd, &ckh, 2, ckh_pointer_hash,
|
||||
ckh_pointer_keycomp), "Unexpected ckh_new() error");
|
||||
|
||||
Reference in New Issue
Block a user