diff --git a/include/haproxy/activity.h b/include/haproxy/activity.h index dbc8ec3a8..e6cb09bbf 100644 --- a/include/haproxy/activity.h +++ b/include/haproxy/activity.h @@ -35,6 +35,12 @@ struct sched_activity *sched_activity_entry(struct sched_activity *array, const #ifdef USE_MEMORY_PROFILING struct memprof_stats *memprof_get_bin(const void *ra, enum memprof_method meth); +void memprof_remove_stale_info(const void *info); +#else +static inline void memprof_remove_stale_info(const void *info) +{ + /* nothing to do */ +} #endif #endif /* _HAPROXY_ACTIVITY_H */ diff --git a/src/activity.c b/src/activity.c index d65508856..b6939d9d5 100644 --- a/src/activity.c +++ b/src/activity.c @@ -324,6 +324,23 @@ void free(void *ptr) _HA_ATOMIC_ADD(&bin->free_tot, size_before); } +/* remove info from entries matching . This needs to be used by callers + * of pool_destroy() so that we don't keep a reference to a dead pool. Nothing + * is done if is NULL. + */ +void memprof_remove_stale_info(const void *info) +{ + int i; + + if (!info) + return; + + for (i = 0; i < MEMPROF_HASH_BUCKETS; i++) { + if (_HA_ATOMIC_LOAD(&memprof_stats[i].info) == info) + _HA_ATOMIC_STORE(&memprof_stats[i].info, NULL); + } +} + #endif // USE_MEMORY_PROFILING /* Updates the current thread's statistics about stolen CPU time. The unit for