]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
fixup: Slightly safer destinationReceipt cleanup
authorAlex Rousskov <rousskov@measurement-factory.com>
Wed, 14 Jul 2021 15:58:15 +0000 (11:58 -0400)
committerAlex Rousskov <rousskov@measurement-factory.com>
Wed, 14 Jul 2021 15:58:15 +0000 (11:58 -0400)
* Removed cleanupOnFail()/saveError() call order dependency.
* Do not leave invalidated destinationReceipt behind reinstatePath()

src/FwdState.cc

index d1f14a006e851099898e4bfb0acb08feac644080..0bd0d862ab0fa8c622d27ad0bf439e15e5ba679e 100644 (file)
@@ -463,6 +463,7 @@ FwdState::fail(ErrorState * errorState)
 {
     cleanupOnFail(errorState->type);
     saveError(errorState);
+    destinationReceipt = nullptr; // may already be nil
 }
 
 /// remembers an error for future use
@@ -474,8 +475,6 @@ FwdState::saveError(ErrorState *errorState)
     delete err;
     err = errorState;
 
-    destinationReceipt = nullptr;
-
     if (!errorState->request)
         errorState->request = request;
 }
@@ -490,8 +489,10 @@ FwdState::cleanupOnFail(const err_type errType)
     if (pconnRace == racePossible) {
         debugs(17, 5, "pconn race happened");
         pconnRace = raceHappened;
-        if (destinationReceipt)
+        if (destinationReceipt) {
             destinations->reinstatePath(destinationReceipt);
+            destinationReceipt = nullptr;
+        }
     }
 
     if (ConnStateData *pinned_connection = request->pinnedConnection()) {