]> source.dussan.org Git - rspamd.git/commitdiff
* Fix reconfigure process of surbl module
authorVsevolod Stakhov <vsevolod@rambler-co.ru>
Mon, 28 Jun 2010 11:59:46 +0000 (15:59 +0400)
committerVsevolod Stakhov <vsevolod@rambler-co.ru>
Mon, 28 Jun 2010 11:59:46 +0000 (15:59 +0400)
* Fix destroying smtp session (unmap memory and do not delete pool early)

src/plugins/surbl.c
src/smtp.c

index 6faaa7c8a0889aacf3752990752484fcef178b33..fbe7c6c596363eaed35836b1b0100b56c49fd1db 100644 (file)
@@ -277,9 +277,30 @@ surbl_module_config (struct config_file *cfg)
 int
 surbl_module_reconfig (struct config_file *cfg)
 {
+       /* Delete pool and objects */
        memory_pool_delete (surbl_module_ctx->surbl_pool);
-       surbl_module_ctx->surbl_pool = memory_pool_new (1024);
+       /* Reinit module */
+       surbl_module_ctx->filter = surbl_filter;
+       surbl_module_ctx->use_redirector = 0;
+       surbl_module_ctx->suffixes = NULL;
+       surbl_module_ctx->bits = NULL;
+       surbl_module_ctx->surbl_pool = memory_pool_new (memory_pool_get_size ());
 
+       surbl_module_ctx->tld2_file = NULL;
+       surbl_module_ctx->whitelist_file = NULL;
+
+       surbl_module_ctx->redirector_hosts = g_hash_table_new (rspamd_strcase_hash, rspamd_strcase_equal);
+       surbl_module_ctx->whitelist = g_hash_table_new (rspamd_strcase_hash, rspamd_strcase_equal);
+       /* Zero exceptions hashes */
+       surbl_module_ctx->exceptions = memory_pool_alloc0 (surbl_module_ctx->surbl_pool, MAX_LEVELS * sizeof (GHashTable *));
+       /* Register destructors */
+       memory_pool_add_destructor (surbl_module_ctx->surbl_pool, (pool_destruct_func) g_hash_table_destroy, surbl_module_ctx->whitelist);
+       memory_pool_add_destructor (surbl_module_ctx->surbl_pool, (pool_destruct_func) g_hash_table_destroy, surbl_module_ctx->redirector_hosts);
+
+       memory_pool_add_destructor (surbl_module_ctx->surbl_pool, (pool_destruct_func) g_list_free, surbl_module_ctx->suffixes);
+       memory_pool_add_destructor (surbl_module_ctx->surbl_pool, (pool_destruct_func) g_list_free, surbl_module_ctx->bits);
+       
+       /* Perform configure */
        return surbl_module_config (cfg);
 }
 
index 1b95a52bb2adc11d0e16b572722a88b205a1d97c..4f1bfaa198a7e5c30f826bdae5f378dee74cbb7a 100644 (file)
@@ -85,6 +85,9 @@ free_smtp_session (gpointer arg)
        if (session) {
                if (session->task) {
                        free_task (session->task, FALSE);
+                       if (session->task->msg->begin) {
+                               munmap (session->task->msg->begin, session->task->msg->len);
+                       }
                }
                if (session->rcpt) {
                        g_list_free (session->rcpt);
@@ -92,7 +95,6 @@ free_smtp_session (gpointer arg)
                if (session->dispatcher) {
                        rspamd_remove_dispatcher (session->dispatcher);
                }
-               memory_pool_delete (session->pool);
                close (session->sock);
                if (session->temp_name != NULL) {
                        unlink (session->temp_name);
@@ -100,6 +102,7 @@ free_smtp_session (gpointer arg)
                if (session->temp_fd != -1) {
                        close (session->temp_fd);
                }
+               memory_pool_delete (session->pool);
                g_free (session);
        }
 }
@@ -400,6 +403,7 @@ process_smtp_data (struct smtp_session *session)
                }
        }
        else {
+               session->task = NULL;
                return smtp_send_upstream_message (session);
        }