From dc073fd7790591430d2b54c033e838a8894c54b6 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 14 Mar 2011 16:11:10 +0300 Subject: Fix another race. --- src/plugins/surbl.c | 49 +++++++++++++++++++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 12 deletions(-) diff --git a/src/plugins/surbl.c b/src/plugins/surbl.c index 90ee260fd..b79f21e94 100644 --- a/src/plugins/surbl.c +++ b/src/plugins/surbl.c @@ -798,14 +798,6 @@ free_redirector_session (void *ud) event_del (¶m->ev); close (param->sock); - param->task->save.saved--; - make_surbl_requests (param->url, param->task, param->suffix, FALSE); - if (param->task->save.saved == 0) { - /* Call other filters */ - param->task->save.saved = 1; - process_filters (param->task); - } - } static void @@ -833,7 +825,13 @@ redirector_callback (gint fd, short what, void *arg) msg_err ("write failed %s to %s", strerror (errno), param->redirector->name); upstream_fail (¶m->redirector->up, param->task->tv.tv_sec); remove_normal_event (param->task->s, free_redirector_session, param); - + param->task->save.saved--; + make_surbl_requests (param->url, param->task, param->suffix, FALSE); + if (param->task->save.saved == 0) { + /* Call other filters */ + param->task->save.saved = 1; + process_filters (param->task); + } return; } param->state = STATE_READ; @@ -843,7 +841,13 @@ redirector_callback (gint fd, short what, void *arg) param->task->message_id, param->redirector->name); upstream_fail (¶m->redirector->up, param->task->tv.tv_sec); remove_normal_event (param->task->s, free_redirector_session, param); - + param->task->save.saved--; + make_surbl_requests (param->url, param->task, param->suffix, FALSE); + if (param->task->save.saved == 0) { + /* Call other filters */ + param->task->save.saved = 1; + process_filters (param->task); + } return; } break; @@ -854,7 +858,13 @@ redirector_callback (gint fd, short what, void *arg) msg_err ("read failed: %s from %s", strerror (errno), param->redirector->name); upstream_fail (¶m->redirector->up, param->task->tv.tv_sec); remove_normal_event (param->task->s, free_redirector_session, param); - + param->task->save.saved--; + make_surbl_requests (param->url, param->task, param->suffix, FALSE); + if (param->task->save.saved == 0) { + /* Call other filters */ + param->task->save.saved = 1; + process_filters (param->task); + } return; } @@ -874,6 +884,13 @@ redirector_callback (gint fd, short what, void *arg) parse_uri (param->url, memory_pool_strdup (param->task->task_pool, c), param->task->task_pool); } } + param->task->save.saved--; + make_surbl_requests (param->url, param->task, param->suffix, FALSE); + if (param->task->save.saved == 0) { + /* Call other filters */ + param->task->save.saved = 1; + process_filters (param->task); + } upstream_ok (¶m->redirector->up, param->task->tv.tv_sec); remove_normal_event (param->task->s, free_redirector_session, param); } @@ -881,6 +898,13 @@ redirector_callback (gint fd, short what, void *arg) msg_info ("<%s> reading redirector %s timed out, while waiting for read", param->redirector->name, param->task->message_id); upstream_fail (¶m->redirector->up, param->task->tv.tv_sec); + param->task->save.saved--; + make_surbl_requests (param->url, param->task, param->suffix, FALSE); + if (param->task->save.saved == 0) { + /* Call other filters */ + param->task->save.saved = 1; + process_filters (param->task); + } remove_normal_event (param->task->s, free_redirector_session, param); } break; @@ -936,7 +960,7 @@ static gboolean surbl_tree_url_callback (gpointer key, gpointer value, void *data) { struct redirector_param *param = data; - struct worker_task *task = param->task; + struct worker_task *task; struct uri *url = value; f_str_t f; gchar *red_domain; @@ -944,6 +968,7 @@ surbl_tree_url_callback (gpointer key, gpointer value, void *data) GRegex *re; guint idx, len; + task = param->task; debug_task ("check url %s", struri (url)); if (url->hostlen <= 0) { -- cgit v1.2.3