From 8c9a47cff8e74fdd80f1905e3f4f8e51fbaac18d Mon Sep 17 00:00:00 2001 From: Eduard Bagdasaryan Date: Thu, 9 Jul 2020 15:41:23 +0300 Subject: [PATCH] Reset the connection establishment 'state' flags on a general error ... such as an exception caught in advanceDestination(). This is an old bug: I assume it can lead to an assertion in establishTunnelThruProxy() if another destination is being attempted after the previous failure. --- src/tunnel.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/tunnel.cc b/src/tunnel.cc index 63bca37985..c9365ff9fd 100644 --- a/src/tunnel.cc +++ b/src/tunnel.cc @@ -272,6 +272,8 @@ private: /// server connection is still in use bool usingDestination() const; + void resetStepFlags(); + /// details of the "last tunneling attempt" failure (if it failed) ErrorState *savedError = nullptr; @@ -1195,6 +1197,7 @@ TunnelStateData::advanceDestination(const char *stepDescription, const Comm::Con closePendingConnection(conn, "connection preparation exception"); if (!savedError) saveError(new ErrorState(ERR_CANNOT_FORWARD, Http::scInternalServerError, request.getRaw(), al)); + resetStepFlags(); retryOrBail(stepDescription); } } @@ -1317,6 +1320,14 @@ TunnelStateData::usingDestination() const return securingConnectionToPeer || waitingForConnectExchange || Comm::IsConnOpen(server.conn); } +void +TunnelStateData::resetStepFlags() +{ + assert(!Comm::IsConnOpen(server.conn)); + securingConnectionToPeer = false; + waitingForConnectExchange = false; +} + /// remembers an error to be used if there will be no more connection attempts void TunnelStateData::saveError(ErrorState *error) -- 2.47.3