From 2ab1ad669e4473d4b268169051000cd8340e5024 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Tue, 22 Apr 2014 18:00:47 +0100 Subject: [PATCH] Reset mempool stat on stat_reset as well. --- src/libutil/mem_pool.c | 26 ++++++++++++++++++-------- src/libutil/mem_pool.h | 5 +++++ src/webui.c | 1 + 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/src/libutil/mem_pool.c b/src/libutil/mem_pool.c index 8f1105add1..6ace865a09 100644 --- a/src/libutil/mem_pool.c +++ b/src/libutil/mem_pool.c @@ -645,14 +645,24 @@ rspamd_mempool_cleanup_tmp (rspamd_mempool_t* pool) void rspamd_mempool_stat (rspamd_mempool_stat_t * st) { - st->pools_allocated = mem_pool_stat->pools_allocated; - st->pools_freed = mem_pool_stat->pools_freed; - st->shared_chunks_allocated = mem_pool_stat->shared_chunks_allocated; - st->bytes_allocated = mem_pool_stat->bytes_allocated; - st->chunks_allocated = mem_pool_stat->chunks_allocated; - st->shared_chunks_allocated = mem_pool_stat->shared_chunks_allocated; - st->chunks_freed = mem_pool_stat->chunks_freed; - st->oversized_chunks = mem_pool_stat->oversized_chunks; + if (mem_pool_stat != NULL) { + st->pools_allocated = mem_pool_stat->pools_allocated; + st->pools_freed = mem_pool_stat->pools_freed; + st->shared_chunks_allocated = mem_pool_stat->shared_chunks_allocated; + st->bytes_allocated = mem_pool_stat->bytes_allocated; + st->chunks_allocated = mem_pool_stat->chunks_allocated; + st->shared_chunks_allocated = mem_pool_stat->shared_chunks_allocated; + st->chunks_freed = mem_pool_stat->chunks_freed; + st->oversized_chunks = mem_pool_stat->oversized_chunks; + } +} + +void +rspamd_mempool_stat_reset (void) +{ + if (mem_pool_stat != NULL) { + memset (mem_pool_stat, 0, sizeof (rspamd_mempool_stat_t)); + } } /* By default allocate 8Kb chunks of memory */ diff --git a/src/libutil/mem_pool.h b/src/libutil/mem_pool.h index f759ed60a7..17edf2fb2f 100644 --- a/src/libutil/mem_pool.h +++ b/src/libutil/mem_pool.h @@ -271,6 +271,11 @@ void rspamd_mempool_wunlock_rwlock (rspamd_mempool_rwlock_t *lock); */ void rspamd_mempool_stat (rspamd_mempool_stat_t *st); +/** + * Reset memory pool stat + */ +void rspamd_mempool_stat_reset (void); + /** * Get optimal pool size based on page size for this system * @return size of memory page in system diff --git a/src/webui.c b/src/webui.c index 4707767dc1..a376fb9ae2 100644 --- a/src/webui.c +++ b/src/webui.c @@ -1407,6 +1407,7 @@ rspamd_webui_handle_stat_common (struct rspamd_http_connection_entry *conn_ent, session->ctx->srv->stat->messages_learned = 0; session->ctx->srv->stat->connections_count = 0; session->ctx->srv->stat->control_connections_count = 0; + rspamd_mempool_stat_reset (); } rspamd_webui_send_ucl (conn_ent, top); -- 2.47.3