]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Fix potential race condition for a finished HTTP connections
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 12 Jun 2018 10:59:10 +0000 (11:59 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 12 Jun 2018 10:59:10 +0000 (11:59 +0100)
src/libutil/http.c

index 03dbaa7bd92e79ede9521355f9b4e043ddfd3f69..3155988710e651064394117b0c8e83c5748fa790 100644 (file)
@@ -1183,7 +1183,13 @@ rspamd_http_event_handler (int fd, short what, gpointer ud)
                                                        http_errno_description (priv->parser.http_errno));
                                }
 
-                               conn->error_handler (conn, err);
+                               if (!conn->finished) {
+                                       conn->error_handler (conn, err);
+                               }
+                               else {
+                                       msg_err ("got error after HTTP request is finished: %e", err);
+                               }
+
                                g_error_free (err);
 
                                REF_RELEASE (pbuf);
@@ -1234,7 +1240,14 @@ rspamd_http_event_handler (int fd, short what, gpointer ud)
                                err = g_error_new (HTTP_ERROR, priv->parser.http_errno,
                                                "HTTP parser error: %s",
                                                http_errno_description (priv->parser.http_errno));
-                               conn->error_handler (conn, err);
+
+                               if (!conn->finished) {
+                                       conn->error_handler (conn, err);
+                               }
+                               else {
+                                       msg_err ("got error after HTTP request is finished: %e", err);
+                               }
+
                                g_error_free (err);
 
                                REF_RELEASE (pbuf);