From ee480ff1440259da34d00df1949aa46f61f91a3d Mon Sep 17 00:00:00 2001 From: Amos Jeffries Date: Tue, 6 Nov 2012 05:45:17 -0700 Subject: [PATCH] Bug 3677: Port un-pinning logic changes from 3.3 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 | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/client_side.cc b/src/client_side.cc index 5ef4157701..839b0b8412 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -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 -- 2.47.2