]> source.dussan.org Git - rspamd.git/commitdiff
* Log scan time and scan length of messages
authorVsevolod Stakhov <vsevolod@rambler-co.ru>
Wed, 25 Mar 2009 09:31:39 +0000 (12:31 +0300)
committerVsevolod Stakhov <vsevolod@rambler-co.ru>
Wed, 25 Mar 2009 09:31:39 +0000 (12:31 +0300)
* Remove 2 memory leaks

src/main.h
src/message.c
src/protocol.c
src/util.c
src/util.h
src/worker.c

index e26ab3fdaf7c7b142bf300ba114c157e11b01cee..431ed8f4b33d34481ad910063cdfa061fcbbdc0f 100644 (file)
@@ -184,6 +184,7 @@ struct worker_task {
        char *last_error;                                                                                       /**< last error                                                                         */
        int error_code;                                                                                         /**< code of last error                                                         */
        memory_pool_t *task_pool;                                                                       /**< memory pool for task                                                       */
+       struct timespec ts;                                                                                     /**< time of connection                                                         */
 };
 
 /**
index 561c494570183e6ec6e091e578fa8687875f83db..6d770bbe8d52e46ee44e6a4626e8740bd2c8238b 100644 (file)
@@ -292,6 +292,7 @@ mime_foreach_callback (GMimeObject *part, gpointer user_data)
                if (type == NULL) {
                        msg_warn ("mime_foreach_callback: type of part is unknown, assume text/plain");
                        type = g_mime_content_type_new ("text", "plain");
+                       memory_pool_add_destructor (task->task_pool, (pool_destruct_func)g_mime_content_type_destroy, type);
                }
                wrapper = g_mime_part_get_content_object (GMIME_PART (part));
                if (wrapper != NULL) {
@@ -802,6 +803,7 @@ message_get_header (memory_pool_t *pool, GMimeMessage *message, const char *fiel
                                        while (ia && ia->address) {
 
                                                ia_string = internet_address_to_string ((InternetAddress *)ia->address, FALSE);
+                                               memory_pool_add_destructor (pool, (pool_destruct_func)g_free, ia_string);
                                                gret = g_list_prepend (gret, ia_string);
                                                ia = ia->next;
                                        }
@@ -809,6 +811,7 @@ message_get_header (memory_pool_t *pool, GMimeMessage *message, const char *fiel
                                        i = internet_address_list_length (ia);
                                        while (i > 0) {
                                                ia_string = internet_address_to_string (internet_address_list_get_address (ia, i), FALSE);
+                                               memory_pool_add_destructor (pool, (pool_destruct_func)g_free, ia_string);
                                                gret = g_list_prepend (gret, ia_string);
                                                -- i;
                                        }
index 6230495bf4bac1d7ac70b56ec3958c1bd288a98c..c9e4925ff2a3c107fe2402da3e46ba7d78d4876d 100644 (file)
@@ -24,6 +24,7 @@
 
 #include "config.h"
 #include "main.h"
+#include "util.h"
 #include "cfg_file.h"
 
 /* Max line size as it is defined in rfc2822 */
@@ -485,7 +486,8 @@ show_metric_result (gpointer metric_name, gpointer metric_value, void *user_data
        if (task->cmd == CMD_SYMBOLS && metric_value != NULL) {
                show_metric_symbols (metric_res, cd);
        }
-       cd->log_offset += snprintf (cd->log_buf + cd->log_offset, cd->log_size - cd->log_offset, "] )");
+       cd->log_offset += snprintf (cd->log_buf + cd->log_offset, cd->log_size - cd->log_offset, "] ), len: %ld, time: %ldms",
+                                                       (long int)task->msg->len, calculate_check_time (&task->ts));
 }
 
 static int
index 1fdd2758ad12d819dd68a1d329b4c9abe1135842..ef9531bd32f7ded8bc2c3e57c9638f709bb2fab8 100644 (file)
@@ -787,6 +787,20 @@ resolve_stat_filename (memory_pool_t *pool, char *pattern, char *rcpt, char *fro
        return new;
 }
 
+long int
+calculate_check_time (struct timespec *begin)
+{
+       struct timespec ts;
+       long int res;
+       
+       clock_gettime (CLOCK_REALTIME, &ts);
+
+       res = (ts.tv_sec - begin->tv_sec) * 1000 + /* Seconds */
+                 (ts.tv_nsec - begin->tv_nsec) / 1000000; /* Nanoseconds */
+
+       return res;
+}
+
 /*
  * vi:ts=4
  */
index fa47f21e19bcfb6533d3963416f1693ac9e0c3ab..67e3d3d010a6100ea14f45acf93b86974dd5350c 100644 (file)
@@ -55,5 +55,6 @@ void file_log_function (const gchar *log_domain, GLogLevelFlags log_level, const
 
 /* Replace %r with rcpt value and %f with from value, new string is allocated in pool */
 char* resolve_stat_filename (memory_pool_t *pool, char *pattern, char *rcpt, char *from);
+long int calculate_check_time (struct timespec *begin);
 
 #endif
index bf5dfa1591657cea75d466afc9f3b4b5104e4e39..295f331dce0085a0e101f59d0e5094d7bcaf2fb5 100644 (file)
@@ -254,6 +254,7 @@ accept_socket (int fd, short what, void *arg)
        new_task->state = READ_COMMAND;
        new_task->sock = nfd;
        new_task->cfg = worker->srv->cfg;
+       clock_gettime (CLOCK_REALTIME, &new_task->ts);
        io_tv.tv_sec = WORKER_IO_TIMEOUT;
        io_tv.tv_usec = 0;
        TAILQ_INIT (&new_task->urls);