mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-07-23 09:07:18 +03:00
Guard prof_active reset by opt_prof
Set `prof_active` to read-only when `opt_prof` is turned off.
This commit is contained in:
parent
1df9dd3515
commit
beb7c16e94
4 changed files with 49 additions and 2 deletions
10
src/ctl.c
10
src/ctl.c
|
|
@ -2662,7 +2662,8 @@ prof_active_ctl(tsd_t *tsd, const size_t *mib, size_t miblen,
|
|||
bool oldval;
|
||||
|
||||
if (!config_prof) {
|
||||
return ENOENT;
|
||||
ret = ENOENT;
|
||||
goto label_return;
|
||||
}
|
||||
|
||||
if (newp != NULL) {
|
||||
|
|
@ -2670,7 +2671,12 @@ prof_active_ctl(tsd_t *tsd, const size_t *mib, size_t miblen,
|
|||
ret = EINVAL;
|
||||
goto label_return;
|
||||
}
|
||||
oldval = prof_active_set(tsd_tsdn(tsd), *(bool *)newp);
|
||||
bool val = *(bool *)newp;
|
||||
if (!opt_prof && val) {
|
||||
ret = ENOENT;
|
||||
goto label_return;
|
||||
}
|
||||
oldval = prof_active_set(tsd_tsdn(tsd), val);
|
||||
} else {
|
||||
oldval = prof_active_get(tsd_tsdn(tsd));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -788,6 +788,7 @@ bool
|
|||
prof_active_get(tsdn_t *tsdn) {
|
||||
bool prof_active_current;
|
||||
|
||||
prof_active_assert();
|
||||
malloc_mutex_lock(tsdn, &prof_active_mtx);
|
||||
prof_active_current = prof_active;
|
||||
malloc_mutex_unlock(tsdn, &prof_active_mtx);
|
||||
|
|
@ -798,10 +799,12 @@ bool
|
|||
prof_active_set(tsdn_t *tsdn, bool active) {
|
||||
bool prof_active_old;
|
||||
|
||||
prof_active_assert();
|
||||
malloc_mutex_lock(tsdn, &prof_active_mtx);
|
||||
prof_active_old = prof_active;
|
||||
prof_active = active;
|
||||
malloc_mutex_unlock(tsdn, &prof_active_mtx);
|
||||
prof_active_assert();
|
||||
return prof_active_old;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue