]> git.ipfire.org Git - thirdparty/rspamd.git/commitdiff
Reset mempool stat on stat_reset as well.
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 22 Apr 2014 17:00:47 +0000 (18:00 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 22 Apr 2014 17:00:47 +0000 (18:00 +0100)
src/libutil/mem_pool.c
src/libutil/mem_pool.h
src/webui.c

index 8f1105add19eed5ec0f216f684cf1a819b400556..6ace865a0909e0344d0cc702b6fc332037947526 100644 (file)
@@ -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 */
index f759ed60a7af51df439827277a5d4ece95ab35a5..17edf2fb2faf4f851803631da3bb9fda6b9488de 100644 (file)
@@ -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
index 4707767dc1b5b245f899f49d486726d2416b8c9e..a376fb9ae2c2ad64dd2b339a7f89a690b6c1e153 100644 (file)
@@ -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);