]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
FwdState::advanceDestination(): do cleanup regardless of the old error
authorEduard Bagdasaryan <eduard.bagdasaryan@measurement-factory.com>
Mon, 13 Jul 2020 13:56:15 +0000 (16:56 +0300)
committerEduard Bagdasaryan <eduard.bagdasaryan@measurement-factory.com>
Mon, 13 Jul 2020 13:56:15 +0000 (16:56 +0300)
src/FwdState.cc
src/FwdState.h

index 57be02b16b7192cc7e8056b6ac842fbc982027f5..15749ab4758d7801f17349d8eca217d27104c961 100644 (file)
@@ -466,29 +466,38 @@ FwdState::useDestinations()
         stopAndDestroy("tried all destinations");
     }
 }
-
 void
 FwdState::fail(ErrorState * errorState)
+{
+    cleanup();
+    doFail(errorState);
+}
+
+void
+FwdState::doFail(ErrorState * errorState)
 {
     debugs(17, 3, err_type_str[errorState->type] << " \"" << Http::StatusCodeString(errorState->httpStatus) << "\"\n\t" << entry->url());
 
     delete err;
     err = errorState;
 
-    const auto oldDestinationReceipt = destinationReceipt;
     destinationReceipt = nullptr;
 
     if (!errorState->request)
         errorState->request = request;
+}
 
+void
+FwdState::cleanup()
+{
     if (err->type != ERR_ZERO_SIZE_OBJECT)
         return;
 
     if (pconnRace == racePossible) {
         debugs(17, 5, HERE << "pconn race happened");
         pconnRace = raceHappened;
-        if (oldDestinationReceipt)
-            destinations->reinstatePath(oldDestinationReceipt);
+        if (destinationReceipt)
+            destinations->reinstatePath(destinationReceipt);
     }
 
     if (ConnStateData *pinned_connection = request->pinnedConnection()) {
@@ -798,9 +807,10 @@ FwdState::advanceDestination(const char *stepDescription, const Comm::Connection
     } catch (...) {
         debugs (17, 2, "exception while trying to " << stepDescription << ": " << CurrentException);
         closePendingConnection(conn, "connection preparation exception");
+        cleanup();
         if (!err) {
             auto error = new ErrorState(ERR_GATEWAY_FAILURE, Http::scInternalServerError, request, al);
-            fail(error);
+            doFail(error);
         }
         retryOrBail();
     }
index d29460b050ca617488323897ae95f78d161a0392..f091caf6ba81b13e94321d57d14194395dc50bbb 100644 (file)
@@ -171,6 +171,9 @@ private:
 
     void notifyConnOpener();
 
+    void doFail(ErrorState *err);
+    void cleanup();
+
 public:
     StoreEntry *entry;
     HttpRequest *request;