Fix the "epoch" mallctl.

Fix the "epoch" mallctl to update cached stats even if the passed in
epoch is 0.
This commit is contained in:
Jason Evans 2012-04-25 13:12:46 -07:00
parent f54166e7ef
commit 6b9ed67b4b
2 changed files with 13 additions and 12 deletions

View File

@ -81,6 +81,8 @@ found in the git revision history:
- Check for NULL pointer in malloc_usable_size(). - Check for NULL pointer in malloc_usable_size().
- Fix an off-by-one heap profile statistics bug that could be observed in - Fix an off-by-one heap profile statistics bug that could be observed in
interval- and growth-triggered heap profiles. interval- and growth-triggered heap profiles.
- Fix the "epoch" mallctl to update cached stats even if the passed in epoch
is 0.
- Fix bin->runcur management to fix a layout policy bug. This bug did not - Fix bin->runcur management to fix a layout policy bug. This bug did not
affect correctness. affect correctness.
- Fix a bug in choose_arena_hard() that potentially caused more arenas to be - Fix a bug in choose_arena_hard() that potentially caused more arenas to be

View File

@ -831,14 +831,14 @@ ctl_boot(void)
#define READONLY() do { \ #define READONLY() do { \
if (newp != NULL || newlen != 0) { \ if (newp != NULL || newlen != 0) { \
ret = EPERM; \ ret = EPERM; \
goto label_return; \ goto label_return; \
} \ } \
} while (0) } while (0)
#define WRITEONLY() do { \ #define WRITEONLY() do { \
if (oldp != NULL || oldlenp != NULL) { \ if (oldp != NULL || oldlenp != NULL) { \
ret = EPERM; \ ret = EPERM; \
goto label_return; \ goto label_return; \
} \ } \
} while (0) } while (0)
@ -854,7 +854,7 @@ ctl_boot(void)
? sizeof(t) : *oldlenp; \ ? sizeof(t) : *oldlenp; \
memcpy(oldp, (void *)&v, copylen); \ memcpy(oldp, (void *)&v, copylen); \
ret = EINVAL; \ ret = EINVAL; \
goto label_return; \ goto label_return; \
} else \ } else \
*(t *)oldp = v; \ *(t *)oldp = v; \
} \ } \
@ -864,7 +864,7 @@ ctl_boot(void)
if (newp != NULL) { \ if (newp != NULL) { \
if (newlen != sizeof(t)) { \ if (newlen != sizeof(t)) { \
ret = EINVAL; \ ret = EINVAL; \
goto label_return; \ goto label_return; \
} \ } \
v = *(t *)newp; \ v = *(t *)newp; \
} \ } \
@ -891,7 +891,7 @@ n##_ctl(const size_t *mib, size_t miblen, void *oldp, size_t *oldlenp, \
READ(oldval, t); \ READ(oldval, t); \
\ \
ret = 0; \ ret = 0; \
label_return: \ label_return: \
if (l) \ if (l) \
malloc_mutex_unlock(&ctl_mtx); \ malloc_mutex_unlock(&ctl_mtx); \
return (ret); \ return (ret); \
@ -913,7 +913,7 @@ n##_ctl(const size_t *mib, size_t miblen, void *oldp, size_t *oldlenp, \
READ(oldval, t); \ READ(oldval, t); \
\ \
ret = 0; \ ret = 0; \
label_return: \ label_return: \
malloc_mutex_unlock(&ctl_mtx); \ malloc_mutex_unlock(&ctl_mtx); \
return (ret); \ return (ret); \
} }
@ -932,7 +932,7 @@ n##_ctl(const size_t *mib, size_t miblen, void *oldp, size_t *oldlenp, \
READ(oldval, t); \ READ(oldval, t); \
\ \
ret = 0; \ ret = 0; \
label_return: \ label_return: \
malloc_mutex_unlock(&ctl_mtx); \ malloc_mutex_unlock(&ctl_mtx); \
return (ret); \ return (ret); \
} }
@ -956,7 +956,7 @@ n##_ctl(const size_t *mib, size_t miblen, void *oldp, size_t *oldlenp, \
READ(oldval, t); \ READ(oldval, t); \
\ \
ret = 0; \ ret = 0; \
label_return: \ label_return: \
return (ret); \ return (ret); \
} }
@ -973,7 +973,7 @@ n##_ctl(const size_t *mib, size_t miblen, void *oldp, size_t *oldlenp, \
READ(oldval, t); \ READ(oldval, t); \
\ \
ret = 0; \ ret = 0; \
label_return: \ label_return: \
return (ret); \ return (ret); \
} }
@ -990,7 +990,7 @@ n##_ctl(const size_t *mib, size_t miblen, void *oldp, size_t *oldlenp, \
READ(oldval, bool); \ READ(oldval, bool); \
\ \
ret = 0; \ ret = 0; \
label_return: \ label_return: \
return (ret); \ return (ret); \
} }
@ -1004,9 +1004,8 @@ epoch_ctl(const size_t *mib, size_t miblen, void *oldp, size_t *oldlenp,
uint64_t newval; uint64_t newval;
malloc_mutex_lock(&ctl_mtx); malloc_mutex_lock(&ctl_mtx);
newval = 0;
WRITE(newval, uint64_t); WRITE(newval, uint64_t);
if (newval != 0) if (newp != NULL)
ctl_refresh(); ctl_refresh();
READ(ctl_epoch, uint64_t); READ(ctl_epoch, uint64_t);