aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/bloom.c2
-rw-r--r--src/plugins/fuzzy_check.c18
2 files changed, 17 insertions, 3 deletions
diff --git a/src/bloom.c b/src/bloom.c
index 8c6bf8edc..eebaac009 100644
--- a/src/bloom.c
+++ b/src/bloom.c
@@ -168,7 +168,7 @@ bloom_create (size_t size, size_t nfuncs, ...)
if (!(bloom = g_malloc (sizeof (bloom_filter_t)))) {
return NULL;
}
- if (!(bloom->a = g_new (char, (size + CHAR_BIT - 1) / CHAR_BIT * SIZE_BIT))) {
+ if (!(bloom->a = g_new0 (char, (size + CHAR_BIT - 1) / CHAR_BIT * SIZE_BIT))) {
g_free (bloom);
return NULL;
}
diff --git a/src/plugins/fuzzy_check.c b/src/plugins/fuzzy_check.c
index 209788feb..ead1e2c83 100644
--- a/src/plugins/fuzzy_check.c
+++ b/src/plugins/fuzzy_check.c
@@ -265,6 +265,17 @@ fuzzy_io_callback (int fd, short what, void *arg)
}
static void
+fuzzy_free_session (void *arg)
+{
+ struct fuzzy_learn_session *session = arg;
+
+ event_del (&session->ev);
+ if (session->task) {
+ free_task (session->task, FALSE);
+ }
+}
+
+static void
fuzzy_learn_callback (int fd, short what, void *arg)
{
struct fuzzy_learn_session *session = arg;
@@ -298,7 +309,6 @@ fuzzy_learn_callback (int fd, short what, void *arg)
msg_err ("fuzzy_learn_callback: got error in IO with server %s:%d, %d, %s", session->server->name,
session->server->port, errno, strerror (errno));
ok:
- event_del (&session->ev);
close (fd);
session->task->save.saved --;
if (session->task->save.saved == 0) {
@@ -371,7 +381,8 @@ fuzzy_process_handler (struct controller_session *session, f_str_t *in)
msg_warn ("read_socket: processing of message failed");
task->last_error = "MIME processing error";
task->error_code = RSPAMD_FILTER_ERROR;
- task->state = WRITE_ERROR;
+ free_task (task, FALSE);
+ session->state = WRITE_REPLY;
}
else {
/* Plan new event for writing */
@@ -399,12 +410,14 @@ fuzzy_process_handler (struct controller_session *session, f_str_t *in)
s->server = selected;
s->cmd = cmd;
event_add (&s->ev, &s->tv);
+ memory_pool_add_destructor (session->session_pool, fuzzy_free_session, s);
task->save.saved ++;
}
}
else {
r = snprintf (out_buf, sizeof (out_buf), "cannot write fuzzy hash" CRLF);
rspamd_dispatcher_write (session->dispatcher, out_buf, r, FALSE, FALSE);
+ free_task (task, FALSE);
session->state = WRITE_REPLY;
return;
}
@@ -415,6 +428,7 @@ fuzzy_process_handler (struct controller_session *session, f_str_t *in)
if (task->save.saved == 0) {
r = snprintf (out_buf, sizeof (out_buf), "no hashes written" CRLF);
rspamd_dispatcher_write (session->dispatcher, out_buf, r, FALSE, FALSE);
+ free_task (task, FALSE);
session->state = WRITE_REPLY;
}
}