diff options
author | Julian Andres Klode <jak@debian.org> | 2018-01-03 16:28:59 +0100 |
---|---|---|
committer | Julian Andres Klode <jak@debian.org> | 2018-01-03 16:33:36 +0100 |
commit | 5b197e9de5376e191018562309e2d42123c27a1d (patch) | |
tree | a38e63df8e908344a693cbc5fd8ddc632fab6369 /methods/connect.cc | |
parent | 8d5f26a9e9bd2a7c58a0039fae0c50867047c30f (diff) |
Correctly report transient errors again
Commit 47c0bdc310c8cd62374ca6e6bb456dd183bdfc07 ("report transient
errors as transient error") accidentally changed some connection
failures to become non-transient, because the result of the error
checks where being ignored and then fatal error was returned if an
error was pending - even if that error was trivial.
After the merge of pu/happy-eyeballs2a this becomes a lot clearer,
and easy to fix.
Gbp-Dch: ignore
Regression-Of: 47c0bdc310c8cd62374ca6e6bb456dd183bdfc07
Diffstat (limited to 'methods/connect.cc')
-rw-r--r-- | methods/connect.cc | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/methods/connect.cc b/methods/connect.cc index 334a1d3f3..519031ace 100644 --- a/methods/connect.cc +++ b/methods/connect.cc @@ -447,6 +447,7 @@ static ResultState ConnectToHostname(std::string const &Host, int const Port, // When we have an IP rotation stay with the last IP. auto Addresses = OrderAddresses(LastUsed != nullptr ? LastUsed : LastHostAddr); std::list<Connection> Conns; + ResultState Result = ResultState::SUCCESSFUL; for (auto Addr : Addresses) { @@ -456,13 +457,16 @@ static ResultState ConnectToHostname(std::string const &Host, int const Port, Conns.push_back(std::move(Conn)); - if (WaitAndCheckErrors(Conns, Fd, Owner->ConfigFindI("ConnectionAttemptDelayMsec", 250), false) == ResultState::SUCCESSFUL) + Result = WaitAndCheckErrors(Conns, Fd, Owner->ConfigFindI("ConnectionAttemptDelayMsec", 250), false); + + if (Result == ResultState::SUCCESSFUL) return ResultState::SUCCESSFUL; } - if (WaitAndCheckErrors(Conns, Fd, TimeOut * 1000, true) == ResultState::SUCCESSFUL) - return ResultState::SUCCESSFUL; - + if (!Conns.empty()) + return WaitAndCheckErrors(Conns, Fd, TimeOut * 1000, true); + if (Result != ResultState::SUCCESSFUL) + return Result; if (_error->PendingError() == true) return ResultState::FATAL_ERROR; _error->Error(_("Unable to connect to %s:%s:"), Host.c_str(), ServStr); |