From: Vsevolod Stakhov Date: Fri, 9 Jul 2010 16:55:46 +0000 (+0400) Subject: * Very hard to detect problem with race among error in socket and destroying task... X-Git-Tag: 0.3.1~55 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=0d211727eeee45ce068e23dfdb6b4da96ba59340;p=rspamd.git * 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 --- 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 *