From: Vsevolod Stakhov Date: Tue, 22 Apr 2014 17:00:47 +0000 (+0100) Subject: Reset mempool stat on stat_reset as well. X-Git-Tag: 0.7.0~288 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2ab1ad669e4473d4b268169051000cd8340e5024;p=thirdparty%2Frspamd.git Reset mempool stat on stat_reset as well. --- 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);