From ded246bb61b9b0f4ca658be45c1691844e1dc122 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 5 Aug 2020 11:04:45 +0200 Subject: http: Fix infinite loop on read errors If there was a transient error and the server fd was closed, the code would infinitely retry - it never reached FailCounter >= 2 because it falls through to the end of the loop, which sets FailCounter = 0. Add a continue just like the DNS rotation code has, so that the retry actually fails after 2 attempts. Also rework the error logic to forward the actual error message. --- methods/basehttp.cc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'methods') diff --git a/methods/basehttp.cc b/methods/basehttp.cc index e659da255..cd319fce1 100644 --- a/methods/basehttp.cc +++ b/methods/basehttp.cc @@ -773,16 +773,23 @@ int BaseHttpMethod::Loop() if (Server->IsOpen() == false) { FailCounter++; - _error->Discard(); Server->Close(); + if (FailCounter >= 2) { - Fail(_("Connection failed"),true); + Fail(true); FailCounter = 0; } - + else + { + _error->Discard(); + } + + // Reset the pipeline QueueBack = Queue; + Server->PipelineAnswersReceived = 0; + continue; } else { -- cgit v1.2.3