]> source.dussan.org Git - rspamd.git/commitdiff
[Fix] Fix errors handling in the proxy
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 9 Jun 2016 11:38:41 +0000 (12:38 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 9 Jun 2016 11:38:41 +0000 (12:38 +0100)
src/rspamd_proxy.c

index d9231ec3d4f0674e7e77c6f21bbfb57cbd85293b..844eaf1e81503f437adad1d434b9ac46b7c71611 100644 (file)
@@ -1134,6 +1134,22 @@ proxy_client_finish_handler (struct rspamd_http_connection *conn,
                        }
                }
 
+               rspamd_http_connection_steal_msg (session->client_conn);
+               rspamd_http_message_remove_header (msg, "Content-Length");
+               rspamd_http_message_remove_header (msg, "Key");
+               rspamd_http_connection_reset (session->client_conn);
+
+               /* Reset spamc legacy */
+               if (msg->method >= HTTP_SYMBOLS) {
+                       msg->method = HTTP_GET;
+                       session->is_spamc = TRUE;
+                       msg_info_session ("enabling legacy rspamc mode for session");
+               }
+
+               if (msg->url->len == 0) {
+                       msg->url = rspamd_fstring_append (msg->url, "/check", strlen ("/check"));
+               }
+
                if (backend == NULL) {
                        /* No backend */
                        msg_err_session ("cannot find upstream for %s", host ? hostbuf : "default");
@@ -1153,7 +1169,9 @@ proxy_client_finish_handler (struct rspamd_http_connection *conn,
                                        SOCK_STREAM, TRUE);
 
                        if (session->master_conn->backend_sock == -1) {
-                               msg_err_session ("cannot connect upstream for %s", host ? hostbuf : "default");
+                               msg_err_session ("cannot connect upstream: %s(%s)",
+                                               host ? hostbuf : "default",
+                                               rspamd_inet_address_to_string (rspamd_upstream_addr (session->master_conn->up)));
                                rspamd_upstream_fail (session->master_conn->up);
                                goto err;
                        }
@@ -1163,21 +1181,6 @@ proxy_client_finish_handler (struct rspamd_http_connection *conn,
                        }
 
                        proxy_open_mirror_connections (session);
-                       rspamd_http_connection_steal_msg (session->client_conn);
-                       rspamd_http_message_remove_header (msg, "Content-Length");
-                       rspamd_http_message_remove_header (msg, "Key");
-                       rspamd_http_connection_reset (session->client_conn);
-
-                       /* Reset spamc legacy */
-                       if (msg->method >= HTTP_SYMBOLS) {
-                               msg->method = HTTP_GET;
-                               session->is_spamc = TRUE;
-                               msg_info_session ("enabling legacy rspamc mode for session");
-                       }
-
-                       if (msg->url->len == 0) {
-                               msg->url = rspamd_fstring_append (msg->url, "/check", strlen ("/check"));
-                       }
 
                        session->master_conn->backend_conn = rspamd_http_connection_new (
                                        NULL,