From 056ad4403c6601ce9fdb463119191a91254a9256 Mon Sep 17 00:00:00 2001 From: Alex Rousskov Date: Thu, 25 Jun 2020 09:39:45 +0000 Subject: [PATCH] Avoid FwdState::serverConn while establishing a CONNECT tunnel (#681) Master/v6 commit 25b0ce4 missed two cases where serverConnection() was used prematurely: One case requires --enable-delay-pools, and the other does not actually dereference the prematurely used serverConnection(). Both cases establish a CONNECT tunnel through a cache_peer. --- src/FwdState.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/FwdState.cc b/src/FwdState.cc index c468541b50..a992dc5477 100644 --- a/src/FwdState.cc +++ b/src/FwdState.cc @@ -133,6 +133,7 @@ void FwdState::closeServerConnection(const char *reason) { debugs(17, 3, "because " << reason << "; " << serverConn); + assert(Comm::IsConnOpen(serverConn)); comm_remove_close_handler(serverConn->fd, closeHandler); closeHandler = NULL; fwdPconnPool->noteUses(fd_table[serverConn->fd].pconn.uses); @@ -848,15 +849,16 @@ FwdState::establishTunnelThruProxy(const Comm::ConnectionPointer &conn) "FwdState::tunnelEstablishmentDone", Http::Tunneler::CbDialer(&FwdState::tunnelEstablishmentDone, this)); HttpRequest::Pointer requestPointer = request; - const auto tunneler = new Http::Tunneler(conn, requestPointer, callback, connectingTimeout(serverConnection()), al); + const auto tunneler = new Http::Tunneler(conn, requestPointer, callback, connectingTimeout(conn), al); // TODO: Replace this hack with proper Comm::Connection-Pool association // that is not tied to fwdPconnPool and can handle disappearing pools. tunneler->noteFwdPconnUse = true; #if USE_DELAY_POOLS - Must(serverConnection()->getPeer()); - if (!serverConnection()->getPeer()->options.no_delay) + Must(conn); + Must(conn->getPeer()); + if (!conn->getPeer()->options.no_delay) tunneler->setDelayId(entry->mem_obj->mostBytesAllowed()); #endif AsyncJob::Start(tunneler); -- 2.47.2