]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Replace ConnStateData::getConcurrentRequestCount() with pipeline methods
authorAmos Jeffries <squid3@treenet.co.nz>
Sun, 15 Nov 2015 10:40:52 +0000 (02:40 -0800)
committerAmos Jeffries <squid3@treenet.co.nz>
Sun, 15 Nov 2015 10:40:52 +0000 (02:40 -0800)
src/client_side.cc
src/client_side.h
src/servers/FtpServer.cc
src/tests/stub_client_side.cc

index 06f63d195ae50ea46848af09faea8d6c9caf80a7..b9b5dd97077147f27d5245b2e0a2986ee5e6a518 100644 (file)
@@ -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 *) &currentobject;
-            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" : ""));
index ba6babf7830677c778416cdfb7a49d1838277464..ac6bad745b0d57c7a3fc6be231a69a073215ffd2 100644 (file)
@@ -188,7 +188,6 @@ public:
     bool clientParseRequests();
     void readNextRequest();
     ClientSocketContext::Pointer getCurrentContext() const;
-    int getConcurrentRequestCount() const;
     bool isOpen() const;
 
     // HttpControlMsgSink API
index 8e657eda32796057259867e1a23081f92c3da760..d1bc08e04b225a58473ab4f4251f6bc7f6f81a79 100644 (file)
@@ -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.
index 238455410f97db085e147d6517e8fb9f677f8788..145c86e3c998078232bba9f1cd92e44fab9c3697 100644 (file)
@@ -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)