From c91557fe1ef5e88093d950aedb9645f5330dbf29 Mon Sep 17 00:00:00 2001 From: Alex Rousskov Date: Fri, 30 Jul 2021 18:36:31 -0400 Subject: [PATCH] fixup: Found/marked more Connection ownership/handling rule violations --- src/HappyConnOpener.cc | 3 +++ src/PeerPoolMgr.cc | 1 + src/ident/Ident.cc | 2 ++ src/servers/FtpServer.cc | 2 ++ 4 files changed, 8 insertions(+) diff --git a/src/HappyConnOpener.cc b/src/HappyConnOpener.cc index 30d5100c23..baf3122c18 100644 --- a/src/HappyConnOpener.cc +++ b/src/HappyConnOpener.cc @@ -577,6 +577,7 @@ HappyConnOpener::openFreshConnection(Attempt &attempt, PeerConnectionPointer &de if (!dest->getPeer()) cs->setHost(host_); + // XXX: Do not co-own attempt.path with ConnOpener. attempt.path = dest; attempt.connWait.start(cs, callConnect); @@ -731,6 +732,8 @@ HappyConnOpener::checkForNewConnection() if (!destinations->empty()) { if (!currentPeer) { auto newPrime = destinations->extractFront(); + // XXX: Do not co-own currentPeer Connection with ConnOpener + // (which is activated via startConnecting() below). currentPeer = newPrime; Must(currentPeer); debugs(17, 7, "new peer " << *currentPeer); diff --git a/src/PeerPoolMgr.cc b/src/PeerPoolMgr.cc index cc09b12302..7456697069 100644 --- a/src/PeerPoolMgr.cc +++ b/src/PeerPoolMgr.cc @@ -121,6 +121,7 @@ PeerPoolMgr::handleOpenedConnection(const CommConnectCbParams ¶ms) const auto connector = new Security::BlindPeerConnector(request, params.conn, callback, nullptr, timeLeft); encryptionWait.start(connector, callback); AsyncJob::Start(connector); // will call our callback + // XXX: Exceptions orphan params.conn return; } diff --git a/src/ident/Ident.cc b/src/ident/Ident.cc index a9f1bc3efa..d796e9ed1c 100644 --- a/src/ident/Ident.cc +++ b/src/ident/Ident.cc @@ -271,6 +271,8 @@ Ident::Start(const Comm::ConnectionPointer &conn, IDCB * callback, void *data) state = new IdentStateData; state->hash.key = xstrdup(key); + // XXX: Do not co-own state->conn Connection with ConnOpener. + // copy the conn details. We do not want the original FD to be re-used by IDENT. state->conn = conn->cloneIdentDetails(); // NP: use random port for secure outbound to IDENT_PORT diff --git a/src/servers/FtpServer.cc b/src/servers/FtpServer.cc index 5fb9739848..641ced5fd9 100644 --- a/src/servers/FtpServer.cc +++ b/src/servers/FtpServer.cc @@ -1676,6 +1676,8 @@ Ftp::Server::checkDataConnPre() return false; } + // XXX: Do not co-own dataConn with ConnOpener. + // active transfer: open a data connection from Squid to client typedef CommCbMemFunT Dialer; AsyncCall::Pointer callback = JobCallback(17, 3, Dialer, this, Ftp::Server::connectedForData); -- 2.47.2