From: Amos Jeffries Date: Sun, 15 Nov 2015 10:40:52 +0000 (-0800) Subject: Replace ConnStateData::getConcurrentRequestCount() with pipeline methods X-Git-Tag: SQUID_4_0_3~5^2~22 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e500cc89759333699b981e58e18045e3d2cbbebe;p=thirdparty%2Fsquid.git Replace ConnStateData::getConcurrentRequestCount() with pipeline methods --- diff --git a/src/client_side.cc b/src/client_side.cc index 06f63d195a..b9b5dd9707 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -1556,8 +1556,8 @@ ClientSocketContext::keepaliveNextRequest() * half-closed _AND_ then, sometimes, spending "Timeout" time in * the keepalive "Waiting for next request" state. */ - if (commIsHalfClosed(conn->clientConnection->fd) && (conn->getConcurrentRequestCount() == 0)) { - debugs(33, 3, "ClientSocketContext::keepaliveNextRequest: half-closed client with no pending requests, closing"); + if (commIsHalfClosed(conn->clientConnection->fd) && conn->pipeline.empty()) { + debugs(33, 3, "half-closed client with no pending requests, closing"); conn->clientConnection->close(); return; } @@ -1874,7 +1874,7 @@ ConnStateData::startShutdown() // if connection is idle terminate it now, // otherwise wait for grace period to end - if (getConcurrentRequestCount() == 0) + if (pipeline.empty()) endingShutdown(); } @@ -2260,22 +2260,11 @@ parseHttpRequest(ConnStateData *csd, const Http1::RequestParserPointer &hp) return result; } -int -ConnStateData::getConcurrentRequestCount() const -{ - int result = 0; - ClientSocketContext::Pointer *T; - - for (T = (ClientSocketContext::Pointer *) ¤tobject; - T->getRaw(); T = &(*T)->next, ++result); - return result; -} - bool ConnStateData::connFinishedWithConn(int size) { if (size == 0) { - if (getConcurrentRequestCount() == 0 && inBuf.isEmpty()) { + if (pipeline.empty() && inBuf.isEmpty()) { /* no current or pending requests */ debugs(33, 4, HERE << clientConnection << " closed"); return true; @@ -2673,7 +2662,7 @@ ConnStateData::pipelinePrefetchMax() const bool ConnStateData::concurrentRequestQueueFilled() const { - const int existingRequestCount = getConcurrentRequestCount(); + const int existingRequestCount = pipeline.count(); // default to the configured pipeline size. // add 1 because the head of pipeline is counted in concurrent requests and not prefetch queue @@ -3037,7 +3026,7 @@ void ConnStateData::afterClientRead() { /* Process next request */ - if (getConcurrentRequestCount() == 0) + if (pipeline.empty()) fd_note(clientConnection->fd, "Reading next request"); if (!clientParseRequests()) { @@ -3051,7 +3040,7 @@ ConnStateData::afterClientRead() * be if we have an incomplete request. * XXX: This duplicates ClientSocketContext::keepaliveNextRequest */ - if (getConcurrentRequestCount() == 0 && commIsHalfClosed(clientConnection->fd)) { + if (pipeline.empty() && commIsHalfClosed(clientConnection->fd)) { debugs(33, 5, clientConnection << ": half-closed connection, no completed request parsed, connection closing."); clientConnection->close(); return; @@ -4788,8 +4777,7 @@ ConnStateData::clientPinnedConnectionRead(const CommIoCbParams &io) return; #endif - // We could use getConcurrentRequestCount(), but this may be faster. - const bool clientIsIdle = !getCurrentContext(); + const bool clientIsIdle = pipeline.empty(); debugs(33, 3, "idle pinned " << pinning.serverConnection << " read " << io.size << (clientIsIdle ? " with idle client" : "")); diff --git a/src/client_side.h b/src/client_side.h index ba6babf783..ac6bad745b 100644 --- a/src/client_side.h +++ b/src/client_side.h @@ -188,7 +188,6 @@ public: bool clientParseRequests(); void readNextRequest(); ClientSocketContext::Pointer getCurrentContext() const; - int getConcurrentRequestCount() const; bool isOpen() const; // HttpControlMsgSink API diff --git a/src/servers/FtpServer.cc b/src/servers/FtpServer.cc index 8e657eda32..d1bc08e04b 100644 --- a/src/servers/FtpServer.cc +++ b/src/servers/FtpServer.cc @@ -126,7 +126,7 @@ Ftp::Server::doProcessRequest() // zero pipelinePrefetchMax() ensures that there is only parsed request ClientSocketContext::Pointer context = getCurrentContext(); Must(context != NULL); - Must(getConcurrentRequestCount() == 1); + Must(pipeline.count() == 1); ClientHttpRequest *const http = context->http; assert(http != NULL); @@ -151,7 +151,7 @@ Ftp::Server::doProcessRequest() void Ftp::Server::processParsedRequest(ClientSocketContext *) { - Must(getConcurrentRequestCount() == 1); + Must(pipeline.count() == 1); // Process FTP request asynchronously to make sure FTP // data connection accept callback is fired first. diff --git a/src/tests/stub_client_side.cc b/src/tests/stub_client_side.cc index 238455410f..145c86e3c9 100644 --- a/src/tests/stub_client_side.cc +++ b/src/tests/stub_client_side.cc @@ -41,7 +41,6 @@ void ConnStateData::freeAllContexts() STUB void ConnStateData::notifyAllContexts(const int xerrno) STUB bool ConnStateData::clientParseRequests() STUB_RETVAL(false) void ConnStateData::readNextRequest() STUB -int ConnStateData::getConcurrentRequestCount() const STUB_RETVAL(0) bool ConnStateData::isOpen() const STUB_RETVAL(false) void ConnStateData::sendControlMsg(HttpControlMsg msg) STUB int64_t ConnStateData::mayNeedToReadMoreBody() const STUB_RETVAL(0)