From: Vsevolod Stakhov Date: Tue, 12 Nov 2019 16:55:37 +0000 (+0000) Subject: [Fix] Fix off-by-one in retries for the proxy X-Git-Tag: 2.2~42 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e87526230e690ee824f554f99ef0253cfb5670af;p=rspamd.git [Fix] Fix off-by-one in retries for the proxy --- diff --git a/src/rspamd_proxy.c b/src/rspamd_proxy.c index e56b9b16f..fd5b181f8 100644 --- a/src/rspamd_proxy.c +++ b/src/rspamd_proxy.c @@ -1517,18 +1517,18 @@ proxy_backend_master_error_handler (struct rspamd_http_connection *conn, GError struct rspamd_proxy_session *session; session = bk_conn->s; + session->retries ++; msg_info_session ("abnormally closing connection from backend: %s, error: %e," " retries left: %d", rspamd_inet_address_to_string ( rspamd_upstream_addr_cur (session->master_conn->up)), err, session->ctx->max_retries - session->retries); - session->retries ++; rspamd_upstream_fail (bk_conn->up, FALSE); proxy_backend_close_connection (session->master_conn); - if (session->ctx->max_retries && - session->retries > session->ctx->max_retries) { + if (session->ctx->max_retries > 0 && + session->retries >= session->ctx->max_retries) { msg_err_session ("cannot connect to upstream, maximum retries " "has been reached: %d", session->retries); /* Terminate session immediately */