From 55607161dd04e91b5923ac294cb64bf4f374440f Mon Sep 17 00:00:00 2001 From: dormando Date: Fri, 28 Apr 2023 12:50:49 -0700 Subject: proxy: return 'readvalidate' on be read timeout New backend connections returned 'conntimeout' whether it timed out establishing the TCP connection or if it died waiting for the "version\r\n" response. Now gives a 'readvalidate' if it's already properly connected. --- proxy_network.c | 6 +++++- t/proxyconfig.t | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/proxy_network.c b/proxy_network.c index c95eb89..21da926 100644 --- a/proxy_network.c +++ b/proxy_network.c @@ -891,7 +891,11 @@ static void proxy_beconn_handler(const int fd, const short which, void *arg) { if (which & EV_TIMEOUT) { P_DEBUG("%s: backend timed out while connecting\n", __func__); - _reset_bad_backend(be, P_BE_FAIL_CONNTIMEOUT); + if (be->connecting) { + _reset_bad_backend(be, P_BE_FAIL_CONNTIMEOUT); + } else { + _reset_bad_backend(be, P_BE_FAIL_READVALIDATE); + } _backend_failed(be); return; } diff --git a/t/proxyconfig.t b/t/proxyconfig.t index 1f3158a..b71e533 100644 --- a/t/proxyconfig.t +++ b/t/proxyconfig.t @@ -168,7 +168,7 @@ my @holdbe = (); # avoid having the backends immediately disconnect and pollute my @watchable = $watch_s->can_read(5); is(scalar @watchable, 1, "got new watcher log lines"); - like(<$watcher>, qr/ts=(\S+) gid=\d+ type=proxy_backend error=conntimeout name=\S+ port=11511/, "one backend timed out connecting"); + like(<$watcher>, qr/ts=(\S+) gid=\d+ type=proxy_backend error=readvalidate name=\S+ port=11511/, "one backend timed out connecting"); like(<$watcher>, qr/ts=(\S+) gid=\d+ type=proxy_backend error=markedbad name=\S+ port=11511/, "backend was marked bad"); for my $msrv (@readable) { -- cgit v1.2.1