diff options
author | Julian Andres Klode <julian.klode@canonical.com> | 2020-08-05 11:04:45 +0200 |
---|---|---|
committer | Julian Andres Klode <julian.klode@canonical.com> | 2020-08-05 11:08:16 +0200 |
commit | ded246bb61b9b0f4ca658be45c1691844e1dc122 (patch) | |
tree | ce626252e0c7c70d67428de9950b3de9b6a31541 /methods/basehttp.cc | |
parent | 8761d5a714819f14c62879d1f705e95b270c5d99 (diff) |
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.
Diffstat (limited to 'methods/basehttp.cc')
-rw-r--r-- | methods/basehttp.cc | 13 |
1 files changed, 10 insertions, 3 deletions
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 { |