]> source.dussan.org Git - rspamd.git/commitdiff
Fix another race.
authorVsevolod Stakhov <vsevolod@rambler-co.ru>
Mon, 14 Mar 2011 13:11:10 +0000 (16:11 +0300)
committerVsevolod Stakhov <vsevolod@rambler-co.ru>
Mon, 14 Mar 2011 13:11:10 +0000 (16:11 +0300)
src/plugins/surbl.c

index 90ee260fd059c2913e3bbf1f0b417472b0e3602b..b79f21e94f72f9881a16e6343f5a054bb831cc6b 100644 (file)
@@ -798,14 +798,6 @@ free_redirector_session (void *ud)
 
        event_del (&param->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 (&param->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 (&param->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 (&param->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 (&param->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 (&param->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) {