summaryrefslogtreecommitdiffstats
path: root/src/rspamd_proxy.c
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2019-12-10 10:49:22 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2019-12-10 10:49:22 +0000
commitd538b9d97f80d7ad86d982deca44172a7b7f8c94 (patch)
tree1ca72170d076694689f64751199e4db6a75858a2 /src/rspamd_proxy.c
parentf001e86f0b8618ca47d11edf5508a6cc4b34976c (diff)
downloadrspamd-d538b9d97f80d7ad86d982deca44172a7b7f8c94.tar.gz
rspamd-d538b9d97f80d7ad86d982deca44172a7b7f8c94.zip
[Fix] Select a different upstream on last retransmit
Issue: #3182
Diffstat (limited to 'src/rspamd_proxy.c')
-rw-r--r--src/rspamd_proxy.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/rspamd_proxy.c b/src/rspamd_proxy.c
index 6cc2e592d..2a0cadbf1 100644
--- a/src/rspamd_proxy.c
+++ b/src/rspamd_proxy.c
@@ -1872,8 +1872,25 @@ retry:
goto err;
}
- session->master_conn->up = rspamd_upstream_get (backend->u,
- RSPAMD_UPSTREAM_ROUND_ROBIN, NULL, 0);
+ /* Provide hash key if hashing based on source address is desired */
+ guint hash_len;
+ gpointer hash_key = rspamd_inet_address_get_hash_key (session->client_addr,
+ &hash_len);
+
+ if (session->ctx->max_retries > 1 &&
+ session->retries == session->ctx->max_retries) {
+
+ session->master_conn->up = rspamd_upstream_get_except (backend->u,
+ session->master_conn->up,
+ RSPAMD_UPSTREAM_ROUND_ROBIN,
+ hash_key, hash_len);
+ }
+ else {
+ session->master_conn->up = rspamd_upstream_get (backend->u,
+ RSPAMD_UPSTREAM_ROUND_ROBIN,
+ hash_key, hash_len);
+ }
+
session->master_conn->timeout = backend->timeout;
if (session->master_conn->up == NULL) {