]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bug 3677: Port un-pinning logic changes from 3.3
authorAmos Jeffries <squid3@treenet.co.nz>
Tue, 6 Nov 2012 12:45:17 +0000 (05:45 -0700)
committerAmos Jeffries <squid3@treenet.co.nz>
Tue, 6 Nov 2012 12:45:17 +0000 (05:45 -0700)
Several design changes have been made to pinning in 3.3. One of them
added a safety check to proect close handler removal in the event that
the server connection was already closed.

This ports that protection from 3.3 and fixes at least one code path
leading to bug 3677 assertions.

src/client_side.cc

index 5ef4157701cd48b8c0a30cf8575877781195a1ff..839b0b8412e3b9fb14be0f11d1fc7ead8c8e014d 100644 (file)
@@ -4085,16 +4085,21 @@ ConnStateData::validatePinnedConnection(HttpRequest *request, const struct peer
 void
 ConnStateData::unpinConnection()
 {
+    debugs(33, 3, HERE << pinning.serverConnection);
+
     if (pinning.peer)
         cbdataReferenceDone(pinning.peer);
 
-    if (pinning.closeHandler != NULL) {
-        comm_remove_close_handler(pinning.serverConnection->fd, pinning.closeHandler);
-        pinning.closeHandler = NULL;
-    }
-    /// also close the server side socket, we should not use it for any future requests...
-    if (Comm::IsConnOpen(pinning.serverConnection))
+    if (Comm::IsConnOpen(pinning.serverConnection)) {
+        if (pinning.closeHandler != NULL) {
+            comm_remove_close_handler(pinning.serverConnection->fd, pinning.closeHandler);
+        }
+        /// also close the server side socket, we should not use it for any future requests...
+        // TODO: do not close if called from our close handler?
         pinning.serverConnection->close();
+    }
+    pinning.closeHandler = NULL; // ensure it is unset regardless of the above conditionals
+
     safe_free(pinning.host);
 
     /* NOTE: pinning.pinned should be kept. This combined with fd == -1 at the end of a request indicates that the host