From 0d211727eeee45ce068e23dfdb6b4da96ba59340 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Fri, 9 Jul 2010 20:55:46 +0400 Subject: [PATCH] * Very hard to detect problem with race among error in socket and destroying task while we are writing to socket and go through a hash table --- src/protocol.c | 2 ++ src/worker.c | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/protocol.c b/src/protocol.c index 76627e15e..999de65ab 100644 --- a/src/protocol.c +++ b/src/protocol.c @@ -688,11 +688,13 @@ show_metric_result (gpointer metric_name, gpointer metric_value, void *user_data else { if (! rspamd_dispatcher_write (task->dispatcher, outbuf, r, FALSE, FALSE)) { cd->alive = FALSE; + return; } if (task->cmd == CMD_SYMBOLS && metric_value != NULL) { if (! show_metric_symbols (metric_res, cd)) { cd->alive = FALSE; + return; } } } diff --git a/src/worker.c b/src/worker.c index 11bb24867..10a7aeace 100644 --- a/src/worker.c +++ b/src/worker.c @@ -370,6 +370,7 @@ write_socket (void *arg) switch (task->state) { case WRITE_REPLY: if (! write_reply (task)) { + destroy_session (task->s); return FALSE; } if (ctx->is_custom) { @@ -423,7 +424,9 @@ err_socket (GError * err, void *arg) if (ctx->is_custom) { fin_custom_filters (task); } - destroy_session (task->s); + if (task->state != WRITE_REPLY) { + destroy_session (task->s); + } } struct worker_task * -- 2.39.5