Guard prof related mallctl with opt_prof.

The prof initialization is done only when opt_prof is true.  This change makes
sure the prof_* mallctls only have limited read access (i.e. no access to prof
internals) when opt_prof is false.

In addition, initialize the global prof mutexes even if opt_prof is false.  This
makes sure the mutex stats are set properly.
This commit is contained in:
Qi Wang
2021-09-08 10:58:04 -07:00
committed by Qi Wang
parent 6e848a005e
commit 523cfa55c5
3 changed files with 79 additions and 67 deletions

View File

@@ -914,7 +914,7 @@ TEST_BEGIN(test_prof_active) {
old = true;
expect_d_eq(mallctl("prof.active", &old, &len, &active, len), ENOENT,
"Setting prof_active to true should fail when opt_prof is off");
expect_true(old, "old valud should not be touched when mallctl fails");
expect_true(old, "old value should not be touched when mallctl fails");
active = false;
expect_d_eq(mallctl("prof.active", NULL, NULL, &active, len), 0,
"Setting prof_active to false should succeed when opt_prof is off");