]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
From: Henrik Nordstrom <hno@hem.passagen.se>
authorwessels <>
Thu, 1 Jan 1998 07:05:52 +0000 (07:05 +0000)
committerwessels <>
Thu, 1 Jan 1998 07:05:52 +0000 (07:05 +0000)
The client request processing (with this patch) is as follows:
1. Read request data from the client into a buffer
2. If the queue of pending objects is less than 2, then process the
buffer and queue objects for delivery.
3. Immediately restart request processing when a object is delivered,
since we might have read additional requests into the buffer.

src/client_side.cc
src/store.cc

index c991447715b11a1e129b9730abed3de482a501de..9f3be05a73c29b082cab012a2817ee4d880ad67d 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client_side.cc,v 1.182 1997/12/31 23:57:16 wessels Exp $
+ * $Id: client_side.cc,v 1.183 1998/01/01 00:05:52 wessels Exp $
  *
  * DEBUG: section 33    Client-side Routines
  * AUTHOR: Duane Wessels
@@ -1022,7 +1022,7 @@ clientWriteComplete(int fd, char *bufnotused, size_t size, int errflag, void *da
            } else {
                debug(12, 5) ("clientWriteComplete: FD %d Setting read handler for next request\n", fd);
                fd_note(fd, "Reading next request");
-               commSetSelect(fd, COMM_SELECT_READ, clientReadRequest, conn, 0);
+               clientReadRequest(fd, conn); /* Read next request */
                commSetTimeout(fd, 15, requestTimeout, conn);
            }
        } else {
@@ -1575,12 +1575,27 @@ clientReadRequest(int fd, void *data)
        if (!ignoreErrno(errno)) {
            debug(50, 2) ("clientReadRequest: FD %d: %s\n", fd, xstrerror());
            comm_close(fd);
+           return;
+       } else if(conn->in.offset == 0) {
+           debug(50, 2) ("clientReadRequest: FD %d: no data to process\n");
+           return;
        }
-       return;
+       /* Continue to process previously read data */
+       size=0;
     }
     conn->in.offset += size;
     conn->in.buf[conn->in.offset] = '\0';      /* Terminate the string */
     while (conn->in.offset > 0) {
+       int nrequests;
+       /* Limit the number of concurrent requests to 2 */
+       for (H = &conn->chr, nrequests = 0; *H; H = &(*H)->next, nrequests++);
+       if (nrequests >= 2) {
+           debug(12, 2) ("clientReadRequest: FD %d max concurrent requests reached\n", fd);
+           debug(12, 5) ("clientReadRequest: FD %d defering new request until one is done\n", fd);
+           conn->defer.until = squid_curtime + 100; /* Reset when a request is complete */
+           break;
+       }
+       /* Process request */
        http = parseHttpRequest(conn,
            &method,
            &parser_return_code,
@@ -1596,7 +1611,7 @@ clientReadRequest(int fd, void *data)
             */
            if (conn->in.offset > 0)
                memmove(conn->in.buf, conn->in.buf + http->req_sz, conn->in.size);
-           /* link */
+           /* add to the client request queue */
            for (H = &conn->chr; *H; H = &(*H)->next);
            *H = http;
            conn->nrequests++;
index fae6c5df32ab61d9e4458ea27c030d8ba855eb20..e33e3bbb32c2aec1dad09fdd6007eca8920b8479 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store.cc,v 1.360 1997/12/31 05:53:19 wessels Exp $
+ * $Id: store.cc,v 1.361 1998/01/01 00:05:53 wessels Exp $
  *
  * DEBUG: section 20    Storeage Manager
  * AUTHOR: Harvest Derived
@@ -1842,15 +1842,23 @@ storeEntryValidLength(const StoreEntry * e)
            storeKeyText(e->key));
        return 1;
     }
-    diff = hdr_sz + content_length - e->object_len;
-    if (diff != 0) {
-       debug(20, 3) ("storeEntryValidLength: %d bytes too %s; '%s'\n",
-           diff < 0 ? -diff : diff,
-           diff < 0 ? "small" : "big",
+    if (e->mem_obj->method == METHOD_HEAD) {
+       debug(20, 5) ("storeEntryValidLength: HEAD request: %s\n",
            storeKeyText(e->key));
-       return 0;
+       return 1;
     }
-    return 1;
+    if (e->mem_obj->reply->code == HTTP_NOT_MODIFIED)
+       return 1;
+    if (e->mem_obj->reply->code == HTTP_NO_CONTENT)
+       return 1;
+    diff = hdr_sz + content_length - e->object_len;
+    if (diff == 0)
+       return 1;
+    debug(20, 3) ("storeEntryValidLength: %d bytes too %s; '%s'\n",
+       diff < 0 ? -diff : diff,
+       diff < 0 ? "small" : "big",
+       storeKeyText(e->key));
+    return 0;
 }
 
 static void