]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Reset the connection establishment 'state' flags on a general error
authorEduard Bagdasaryan <eduard.bagdasaryan@measurement-factory.com>
Thu, 9 Jul 2020 12:41:23 +0000 (15:41 +0300)
committerEduard Bagdasaryan <eduard.bagdasaryan@measurement-factory.com>
Thu, 9 Jul 2020 12:41:23 +0000 (15:41 +0300)
... 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

index 63bca3798527a3e3b44e2cec46f8947d024abfe8..c9365ff9fd0980f7f15c9dc3f323daa678c0c93b 100644 (file)
@@ -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)