]> source.dussan.org Git - rspamd.git/commitdiff
* Add statictics for all allocated pools
authorVsevolod Stakhov <vsevolod@rambler-co.ru>
Thu, 26 Mar 2009 15:29:45 +0000 (18:29 +0300)
committerVsevolod Stakhov <vsevolod@rambler-co.ru>
Thu, 26 Mar 2009 15:29:45 +0000 (18:29 +0300)
src/controller.c
src/mem_pool.c
src/mem_pool.h

index 8a56b7f5bed5195b0db9f6158d0a84a7a83c9770..d82cc726e853cf9b8abae74a98cf69379bbd9aed 100644 (file)
@@ -194,6 +194,10 @@ process_command (struct controller_command *cmd, char **cmd_args, struct control
                                                          session->worker->srv->stat->connections_count);
                                r += snprintf (out_buf + r, sizeof (out_buf) - r, "Control connections count: %u" CRLF,
                                                          session->worker->srv->stat->control_connections_count);
+                               r += snprintf (out_buf + r, sizeof (out_buf) - r, "Pools allocated: %ld" CRLF,
+                                                         (long int)mem_st.pools_allocated);
+                               r += snprintf (out_buf + r, sizeof (out_buf) - r, "Pools freed: %ld" CRLF,
+                                                         (long int)mem_st.pools_freed);
                                r += snprintf (out_buf + r, sizeof (out_buf) - r, "Bytes allocated: %ld" CRLF,
                                                          (long int)mem_st.bytes_allocated);
                                r += snprintf (out_buf + r, sizeof (out_buf) - r, "Memory chunks allocated: %ld" CRLF,
index 84ebe9a793f4aae23f6ebacfe6fbecec8f44fd20..ab96483f010a11f761973a4d7dd6d3d99631b7f1 100644 (file)
@@ -142,6 +142,8 @@ memory_pool_new (memory_pool_ssize_t size)
        new->first_pool = new->cur_pool;
        new->destructors = NULL;
 
+       mem_pool_stat->pools_allocated ++;
+
        return new;
 }
 
@@ -387,12 +389,16 @@ memory_pool_delete (memory_pool_t *pool)
                STAT_UNLOCK ();
        }
 
+       mem_pool_stat->pools_freed ++;
        g_free (pool);
 }
 
 void
 memory_pool_stat (memory_pool_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;
index d332a2c115d8c5edbfa684f0652c00004314e1b7..0754afd7ba6f8854e50b7020fc99b721c65f3fe6 100644 (file)
@@ -68,9 +68,11 @@ typedef struct memory_pool_s {
  * Statistics structure
  */
 typedef struct memory_pool_stat_s {
-       memory_pool_ssize_t bytes_allocated;                                    /**< bytes that are allocated with pool allocator               */
+       memory_pool_ssize_t pools_allocated;                            /**< total number of allocated pools                                    */
+       memory_pool_ssize_t pools_freed;                                        /**< number of freed pools                                                              */
+       memory_pool_ssize_t bytes_allocated;                            /**< bytes that are allocated with pool allocator               */
        memory_pool_ssize_t chunks_allocated;                           /**< number of chunks that are allocated                                */
-       memory_pool_ssize_t shared_chunks_allocated;                    /**< shared chunks allocated                                                    */
+       memory_pool_ssize_t shared_chunks_allocated;            /**< shared chunks allocated                                                    */
        memory_pool_ssize_t chunks_freed;                                       /**< chunks freed                                                                               */
 } memory_pool_stat_t;