From 5ccf33a801653b08244323e65723991c4c38ed0d Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 28 Jun 2010 15:59:46 +0400 Subject: [PATCH] * Fix reconfigure process of surbl module * Fix destroying smtp session (unmap memory and do not delete pool early) --- src/plugins/surbl.c | 23 ++++++++++++++++++++++- src/smtp.c | 6 +++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/plugins/surbl.c b/src/plugins/surbl.c index 6faaa7c8a..fbe7c6c59 100644 --- a/src/plugins/surbl.c +++ b/src/plugins/surbl.c @@ -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); } diff --git a/src/smtp.c b/src/smtp.c index 1b95a52bb..4f1bfaa19 100644 --- a/src/smtp.c +++ b/src/smtp.c @@ -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); } -- 2.39.5