]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Summary: Merge delay pools update.
authorrobertc <>
Fri, 14 Feb 2003 05:20:37 +0000 (05:20 +0000)
committerrobertc <>
Fri, 14 Feb 2003 05:20:37 +0000 (05:20 +0000)
Patches applied:

  * robertc@squid-cache.org--squid/squid--delay-class-4--3.0--patch-38
     Smooth delay pools.

src/DelayBucket.cc
src/MemObject.cc
src/http.cc
src/http.h

index 293d29b2d49247277c9d17f87ccff3eb2f0c8960..757bd3f9ecc9e5be2e9eac3679177ec487c0d18c 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: DelayBucket.cc,v 1.1 2003/02/05 10:36:48 robertc Exp $
+ * $Id: DelayBucket.cc,v 1.2 2003/02/13 22:20:37 robertc Exp $
  *
  * DEBUG: section 77    Delay Pools
  * AUTHOR: Robert Collins <robertc@squid-cache.org>
@@ -79,7 +79,8 @@ DelayBucket::update (DelaySpec const &rate, int incr)
 int
 DelayBucket::bytesWanted (int min, int max) const
 {
-    return XMAX(min, XMIN(max, level()));
+    int result = XMAX(min, XMIN(max, level()));
+    return result;
 }
 
 void
index 96d83175e2cfed7cb2beb7da8baa91c0d6321cd9..7e8dabb94317d5cad31df073ff916317ce58b4a4 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: MemObject.cc,v 1.3 2003/02/08 17:43:18 hno Exp $
+ * $Id: MemObject.cc,v 1.4 2003/02/13 22:20:37 robertc Exp $
  *
  * DEBUG: section 19    Store Memory Primitives
  * AUTHOR: Robert Collins
@@ -396,9 +396,17 @@ MemObject::mostBytesAllowed() const
     DelayId result;
     for (dlink_node *node = clients.head; node; node = node->next) {
        store_client *sc = (store_client *) node->data;
+#if 0
+       /* This test is invalid because the client may be writing data
+        * and thus will want data immediately.
+        * If we include the test, there is a race condition when too much
+        * data is read - if all sc's are writing when a read is scheduled.
+        * XXX: fixme.
+        */
        if (!sc->callbackPending())
            /* not waiting for more data */
            continue;
+#endif
        if (sc->getType() != STORE_MEM_CLIENT)
            /* reading off disk */
            continue;
index 0e771125f5e02bec459eeae1dc1572e5fb1e8634..2bb19831e5acfa178cb0a0840d10dcac18623b09 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: http.cc,v 1.407 2003/02/12 06:11:03 robertc Exp $
+ * $Id: http.cc,v 1.408 2003/02/13 22:20:37 robertc Exp $
  *
  * DEBUG: section 11    Hypertext Transfer Protocol (HTTP)
  * AUTHOR: Harvest Derived
@@ -56,7 +56,6 @@ CBDATA_TYPE(HttpStateData);
 
 static const char *const crlf = "\r\n";
 
-static CWCB httpSendComplete;
 static CWCB httpSendRequestEntity;
 
 static IOCB httpReadReply;
@@ -618,17 +617,7 @@ HttpStateData::readReply (int fd, char *readBuf, size_t len, comm_err_t flag, in
 {
     int bin;
     int clen;
-    read_sz = SQUID_TCP_SO_RCVBUF;
     do_next_read = 0;
-#if DELAY_POOLS
-    DelayId delayId;
-
-    /* special "if" only for http (for nodelay proxy conns) */
-    if (DelayPools::IsNoDelay(fd))
-       delayId = DelayId();
-    else
-       delayId = entry->mem_obj->mostBytesAllowed();
-#endif
 
 
     assert(buf == readBuf);
@@ -648,7 +637,13 @@ HttpStateData::readReply (int fd, char *readBuf, size_t len, comm_err_t flag, in
     errno = 0;
     /* prepare the read size for the next read (if any) */
 #if DELAY_POOLS
-    read_sz = delayId.bytesWanted(1, read_sz);
+    DelayId delayId;
+
+    /* special "if" only for http (for nodelay proxy conns) */
+    if (DelayPools::IsNoDelay(fd))
+       delayId = DelayId();
+    else
+       delayId = entry->mem_obj->mostBytesAllowed();
 #endif
     debug(11, 5) ("httpReadReply: FD %d: len %d.\n", fd, (int)len);
     if (flag == COMM_OK && len > 0) {
@@ -821,19 +816,32 @@ HttpStateData::processReplyData(const char *buf, size_t len)
     maybeReadData();
 }
 
+size_t
+HttpStateData::amountToRead()
+{
+    read_sz = SQUID_TCP_SO_RCVBUF;
+#if DELAY_POOLS
+    /* special "if" only for http (for nodelay proxy conns) */
+    if (!DelayPools::IsNoDelay(fd))
+       read_sz = entry->mem_obj->mostBytesAllowed().bytesWanted(1, read_sz);
+#endif
+    debug (11,4)("HttpStateData::amountToRead: Returning %u\n", (unsigned) read_sz);
+    return read_sz;
+}
+
 void
 HttpStateData::maybeReadData()
 {
     if (do_next_read) {
        do_next_read = 0;
-        comm_read(fd, buf, read_sz, httpReadReply, this);
+        comm_read(fd, buf, amountToRead(), httpReadReply, this);
     }
 }
 
 /* This will be called when request write is complete. Schedule read of
  * reply. */
-static void
-httpSendComplete(int fd, char *bufnotused, size_t size, comm_err_t errflag, void *data)
+void
+HttpStateData::SendComplete(int fd, char *bufnotused, size_t size, comm_err_t errflag, void *data)
 {
     HttpStateData *httpState = static_cast<HttpStateData *>(data);
     StoreEntry *entry = httpState->entry;
@@ -859,8 +867,7 @@ httpSendComplete(int fd, char *bufnotused, size_t size, comm_err_t errflag, void
        return;
     } else {
        /* Schedule read reply. */
-       /* XXX we're not taking into account delay pools on this read! */
-       comm_read(fd, httpState->buf, SQUID_TCP_SO_RCVBUF, httpReadReply, httpState);
+       comm_read(fd, httpState->buf, httpState->amountToRead(), httpReadReply, httpState);
        /*
         * Set the read timeout here because it hasn't been set yet.
         * We only set the read timeout after the request has been
@@ -1162,7 +1169,7 @@ httpSendRequest(HttpStateData * httpState)
     if (httpState->orig_request->body_connection)
        sendHeaderDone = httpSendRequestEntity;
     else
-       sendHeaderDone = httpSendComplete;
+       sendHeaderDone = HttpStateData::SendComplete;
 
     if (p != NULL)
        httpState->flags.proxying = 1;
@@ -1263,13 +1270,13 @@ httpSendRequestEntityDone(int fd, void *data)
     ch.request = requestLink(httpState->request);
     if (!Config.accessList.brokenPosts) {
        debug(11, 5) ("httpSendRequestEntityDone: No brokenPosts list\n");
-       httpSendComplete(fd, NULL, 0, COMM_OK, data);
+       HttpStateData::SendComplete(fd, NULL, 0, COMM_OK, data);
     } else if (!aclCheckFast(Config.accessList.brokenPosts, &ch)) {
        debug(11, 5) ("httpSendRequestEntityDone: didn't match brokenPosts\n");
-       httpSendComplete(fd, NULL, 0, COMM_OK, data);
+       HttpStateData::SendComplete(fd, NULL, 0, COMM_OK, data);
     } else {
        debug(11, 2) ("httpSendRequestEntityDone: matched brokenPosts\n");
-       comm_old_write(fd, "\r\n", 2, httpSendComplete, data, NULL);
+       comm_old_write(fd, "\r\n", 2, HttpStateData::SendComplete, data, NULL);
     }
 }
 
@@ -1286,7 +1293,7 @@ httpRequestBodyHandler(char *buf, ssize_t size, void *data)
     } else {
        /* Failed to get whole body, probably aborted */
        memFree8K(buf);
-       httpSendComplete(httpState->fd, NULL, 0, COMM_ERR_CLOSING, data);
+       HttpStateData::SendComplete(httpState->fd, NULL, 0, COMM_ERR_CLOSING, data);
     }
 }
 
index b306c5e9556773769c9f1c9baf24a6b666413ff8..a8fdadf912d4d3c82585b0eafc563173345edcd1 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: http.h,v 1.3 2003/01/23 00:37:22 robertc Exp $
+ * $Id: http.h,v 1.4 2003/02/13 22:20:38 robertc Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -39,6 +39,7 @@
 
 class HttpStateData {
     public:
+      static CWCB SendComplete;
     void processReplyHeader(const char *, int);
     void processReplyData(const char *, size_t);
     IOCB readReply;
@@ -67,6 +68,7 @@ private:
     };
     ConnectionStatus statusIfComplete() const;
     ConnectionStatus persistentConnStatus() const;
+    size_t amountToRead();
 };
 
 #endif /* SQUID_HTTP_H */