--------------------- PatchSet 7104 Date: 2005/10/12 08:19:14 Author: adri Branch: tidyup_deferred_reads Tag: (none) Log: Refactor out the stuff playing with client side defers. The client side defers handles two things: half-closed connection checking (which occurs once a second until it times out) and overflowing a buffer with data. I'll come up with an alternate way of implementing these. Members: src/client_side.c:1.47.2.59.4.1->1.47.2.59.4.2 Index: squid/src/client_side.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/client_side.c,v retrieving revision 1.47.2.59.4.1 retrieving revision 1.47.2.59.4.2 diff -u -r1.47.2.59.4.1 -r1.47.2.59.4.2 --- squid/src/client_side.c 27 Sep 2005 04:57:14 -0000 1.47.2.59.4.1 +++ squid/src/client_side.c 12 Oct 2005 08:19:14 -0000 1.47.2.59.4.2 @@ -1,6 +1,6 @@ /* - * $Id: client_side.c,v 1.47.2.59.4.1 2005/09/27 04:57:14 adri Exp $ + * $Id: client_side.c,v 1.47.2.59.4.2 2005/10/12 08:19:14 adri Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -150,6 +150,7 @@ static void clientEatRequestBody(clientHttpRequest *); static BODY_HANDLER clientReadBody; static void clientAbortBody(request_t * req); +static void clientFinishDefer(int fd, ConnStateData *conn); static int checkAccelOnly(clientHttpRequest * http) @@ -2157,7 +2158,7 @@ ConnStateData *conn = http->conn; StoreEntry *entry; debug(33, 3) ("clientKeepaliveNextRequest: FD %d\n", conn->fd); - conn->defer.until = 0; /* Kick it to read a new request */ + clientFinishDefer(conn->fd, conn); httpRequestFree(http); if ((http = conn->chr) == NULL) { debug(33, 5) ("clientKeepaliveNextRequest: FD %d reading next req\n", @@ -2962,6 +2963,27 @@ } static void +clientDefer(int fd, ConnStateData *conn) +{ + fd_table[fd].flags.socket_eof = 1; + conn->defer.until = squid_curtime + 1; + conn->defer.n++; + fd_note(fd, "half-closed"); +} + +static void +clientDeferLots(int fd, ConnStateData *conn) +{ + conn->defer.until = squid_curtime + 100; /* Reset when a request is complete */ +} + +static void +clientFinishDefer(int fd, ConnStateData *conn) +{ + conn->defer.until = 0; /* Kick it to read a new request */ +} + +static void clientReadRequest(int fd, void *data) { ConnStateData *conn = data; @@ -3023,10 +3045,7 @@ } /* It might be half-closed, we can't tell */ debug(33, 5) ("clientReadRequest: FD %d closed?\n", fd); - F->flags.socket_eof = 1; - conn->defer.until = squid_curtime + 1; - conn->defer.n++; - fd_note(fd, "half-closed"); + clientDefer(fd, conn); /* There is one more close check at the end, to detect aborted * (partial) requests. At this point we can't tell if the request * is partial. @@ -3068,7 +3087,7 @@ if (nrequests >= (Config.onoff.pipeline_prefetch ? 2 : 1)) { debug(33, 3) ("clientReadRequest: FD %d max concurrent requests reached\n", fd); debug(33, 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 */ + clientDeferLots(fd, conn); break; } conn->in.buf[conn->in.offset] = '\0'; /* Terminate the string */