summaryrefslogtreecommitdiffstats
path: root/src/rspamd_proxy.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-02-18 12:58:57 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-02-18 12:58:57 +0000
commit0f32df6f44c75cb9be69618e699fb2972cc7d421 (patch)
treec7be839a23808ac274a0fc5c14c75a55607600ad /src/rspamd_proxy.c
parentc9d04a923e2a64321df8128aa4efaacdfccbed2f (diff)
downloadrspamd-0f32df6f44c75cb9be69618e699fb2972cc7d421.tar.gz
rspamd-0f32df6f44c75cb9be69618e699fb2972cc7d421.zip
[Fix] Core: Fix address rotation bug
Previously, upstream.get_addr function returned the new address of the upstream. Unfortunately, it was used for printing addresses. It caused the following situation: let's imagine we have A1 and A2 where A1 was initially selected. So the connection was performed to A1: Current addr Selected addr Connect+---------+ A2+------>A1 A1 | +-+Print failure<---+ A1+------>A2 A2 | +----+ +->Mark failure+-------->+ A2 | +----+ But the failure OP as well as log message told about `A2` where the real problem happened with `A1`. This commit adds distinguishing between getting the next and the current address of the upstream resolving this issue.
Diffstat (limited to 'src/rspamd_proxy.c')
-rw-r--r--src/rspamd_proxy.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/rspamd_proxy.c b/src/rspamd_proxy.c
index bb0028f0b..31aeceb12 100644
--- a/src/rspamd_proxy.c
+++ b/src/rspamd_proxy.c
@@ -1309,7 +1309,8 @@ proxy_backend_mirror_error_handler (struct rspamd_http_connection *conn, GError
msg_info_session ("abnormally closing connection from backend: %s:%s, "
"error: %e",
bk_conn->name,
- rspamd_inet_address_to_string (rspamd_upstream_addr (bk_conn->up)),
+ rspamd_inet_address_to_string (
+ rspamd_upstream_addr_cur (bk_conn->up)),
err);
if (err) {
@@ -1337,7 +1338,8 @@ proxy_backend_mirror_finish_handler (struct rspamd_http_connection *conn,
bk_conn->parser_from_ref, msg->body_buf.begin, msg->body_buf.len)) {
msg_warn_session ("cannot parse results from the mirror backend %s:%s",
bk_conn->name,
- rspamd_inet_address_to_string (rspamd_upstream_addr (bk_conn->up)));
+ rspamd_inet_address_to_string (
+ rspamd_upstream_addr_cur (bk_conn->up)));
bk_conn->err = "cannot parse ucl";
}
@@ -1387,7 +1389,7 @@ proxy_open_mirror_connections (struct rspamd_proxy_session *session)
}
bk_conn->backend_sock = rspamd_inet_address_connect (
- rspamd_upstream_addr (bk_conn->up),
+ rspamd_upstream_addr_next (bk_conn->up),
SOCK_STREAM, TRUE);
if (bk_conn->backend_sock == -1) {
@@ -1432,7 +1434,7 @@ proxy_open_mirror_connections (struct rspamd_proxy_session *session)
if (m->local ||
rspamd_inet_address_is_local (
- rspamd_upstream_addr (bk_conn->up), FALSE)) {
+ rspamd_upstream_addr_cur (bk_conn->up), FALSE)) {
if (session->fname) {
rspamd_http_message_add_header (msg, "File", session->fname);
@@ -1509,7 +1511,8 @@ proxy_backend_master_error_handler (struct rspamd_http_connection *conn, GError
session = bk_conn->s;
msg_info_session ("abnormally closing connection from backend: %s, error: %e,"
" retries left: %d",
- rspamd_inet_address_to_string (rspamd_upstream_addr (session->master_conn->up)),
+ rspamd_inet_address_to_string (
+ rspamd_upstream_addr_cur (session->master_conn->up)),
err,
session->ctx->max_retries - session->retries);
session->retries ++;
@@ -1531,7 +1534,7 @@ proxy_backend_master_error_handler (struct rspamd_http_connection *conn, GError
msg_info_session ("retry connection to: %s"
" retries left: %d",
rspamd_inet_address_to_string (
- rspamd_upstream_addr (session->master_conn->up)),
+ rspamd_upstream_addr_cur (session->master_conn->up)),
session->ctx->max_retries - session->retries);
}
}
@@ -1821,14 +1824,15 @@ retry:
}
session->master_conn->backend_sock = rspamd_inet_address_connect (
- rspamd_upstream_addr (session->master_conn->up),
+ rspamd_upstream_addr_next (session->master_conn->up),
SOCK_STREAM, TRUE);
if (session->master_conn->backend_sock == -1) {
msg_err_session ("cannot connect upstream: %s(%s)",
host ? hostbuf : "default",
- rspamd_inet_address_to_string (rspamd_upstream_addr (
- session->master_conn->up)));
+ rspamd_inet_address_to_string (
+ rspamd_upstream_addr_cur (
+ session->master_conn->up)));
rspamd_upstream_fail (session->master_conn->up, TRUE);
session->retries ++;
goto retry;
@@ -1872,7 +1876,8 @@ retry:
if (backend->local ||
rspamd_inet_address_is_local (
- rspamd_upstream_addr (session->master_conn->up), FALSE)) {
+ rspamd_upstream_addr_cur (
+ session->master_conn->up), FALSE)) {
if (session->fname) {
rspamd_http_message_add_header (msg, "File", session->fname);