From: Amos Jeffries Date: Wed, 10 Aug 2016 00:56:30 +0000 (+1200) Subject: Cleanup: refactor FwdState pinned connection handling slightly X-Git-Tag: SQUID_4_0_14~39 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b410d56388fc52dd70431fa834b323066c68ef74;p=thirdparty%2Fsquid.git Cleanup: refactor FwdState pinned connection handling slightly Don't try to be too smart with indirect serverConn == NULL details. It just confuses static analysis. This code ordering should resolve the false positive Coverity Scan issue 740373 and let any real problem show through. --- diff --git a/src/FwdState.cc b/src/FwdState.cc index 3390a23650..c78019202a 100644 --- a/src/FwdState.cc +++ b/src/FwdState.cc @@ -847,27 +847,29 @@ FwdState::connectStart() ConnStateData *pinned_connection = request->pinnedConnection(); debugs(17,7, "pinned peer connection: " << pinned_connection); // pinned_connection may become nil after a pconn race - if (pinned_connection) + if (pinned_connection) { serverConn = pinned_connection->borrowPinnedConnection(request, serverDestinations[0]->getPeer()); - else - serverConn = NULL; - if (Comm::IsConnOpen(serverConn)) { - pinned_connection->stopPinnedConnectionMonitoring(); - flags.connected_okay = true; - ++n_tries; - request->flags.pinned = true; - if (pinned_connection->pinnedAuth()) - request->flags.auth = true; - - closeHandler = comm_add_close_handler(serverConn->fd, fwdServerClosedWrapper, this); - - syncWithServerConn(pinned_connection->pinning.host); - - // the server may close the pinned connection before this request - pconnRace = racePossible; - dispatch(); - return; - } + if (Comm::IsConnOpen(serverConn)) { + pinned_connection->stopPinnedConnectionMonitoring(); + flags.connected_okay = true; + ++n_tries; + request->flags.pinned = true; + if (pinned_connection->pinnedAuth()) + request->flags.auth = true; + + closeHandler = comm_add_close_handler(serverConn->fd, fwdServerClosedWrapper, this); + + syncWithServerConn(pinned_connection->pinning.host); + + // the server may close the pinned connection before this request + pconnRace = racePossible; + dispatch(); + return; + } + + } else + serverConn = nullptr; + // Pinned connection failure. debugs(17,2,HERE << "Pinned connection failed: " << pinned_connection); ErrorState *anErr = new ErrorState(ERR_ZERO_SIZE_OBJECT, Http::scServiceUnavailable, request);