--------------------- PatchSet 7087 Date: 2005/10/09 15:47:14 Author: adri Branch: tidyup_deferred_reads Tag: (none) Log: After wondering why the fetches were happening at full speed when testing throughput with my modified squidclient I discovered that I hadn't actually limited the read events in the HTTP code! How silly! The HTTP side now stores the last Kick state from the store side and begins each connection in STKICK_RUN mode (ie, free-running IO reading). The only place I limit reads right now is the body - the IO events are still always registered if we're reading headers or in a keepalive state. Read IO speed is now throttled correctly. Members: src/http.c:1.17.6.27.4.14->1.17.6.27.4.15 src/structs.h:1.48.2.34.4.6->1.48.2.34.4.7 Index: squid/src/http.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/http.c,v retrieving revision 1.17.6.27.4.14 retrieving revision 1.17.6.27.4.15 diff -u -r1.17.6.27.4.14 -r1.17.6.27.4.15 --- squid/src/http.c 9 Oct 2005 07:18:14 -0000 1.17.6.27.4.14 +++ squid/src/http.c 9 Oct 2005 15:47:14 -0000 1.17.6.27.4.15 @@ -1,6 +1,6 @@ /* - * $Id: http.c,v 1.17.6.27.4.14 2005/10/09 07:18:14 adri Exp $ + * $Id: http.c,v 1.17.6.27.4.15 2005/10/09 15:47:14 adri Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -551,6 +551,16 @@ return 1; } + +/* Schedule read if the store side lets us */ +void +httpMaybeReadSchedule(int fd, HttpStateData *httpState) +{ + assert(fd == httpState->fd); + if (httpState->pending_kick == STKICK_FETCH || httpState->pending_kick == STKICK_RUN) + commSetSelect(fd, COMM_SELECT_READ, httpReadReply, httpState, 0); +} + void httpReadSchedule(int fd, HttpStateData *httpState) { @@ -576,6 +586,7 @@ * This won't be very efficient as we may already /have/ scheduled IO, * but we can cross that bridge when we know this works. */ + httpState->pending_kick = type; if (type == STKICK_WAIT) { httpReadClear(httpState->fd, httpState); } else if (type == STKICK_RUN || type == STKICK_FETCH) { @@ -791,7 +802,7 @@ } else { commSetTimeout(fd, Config.Timeout.read, NULL, NULL); } - httpReadSchedule(fd, httpState); + httpMaybeReadSchedule(fd, httpState); return; case -1: /* Server is nasty on us. Shut down */ @@ -1110,6 +1121,8 @@ /* Schedule read reply. (but no timeout set until request fully sent) */ commSetTimeout(fd, Config.Timeout.lifetime, httpTimeout, httpState); + /* Allow free-running IO until the store hints at us otherwise */ + httpState->pending_kick = STKICK_RUN; httpReadSchedule(fd, httpState); if (httpState->orig_request->body_reader) Index: squid/src/structs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/structs.h,v retrieving revision 1.48.2.34.4.6 retrieving revision 1.48.2.34.4.7 diff -u -r1.48.2.34.4.6 -r1.48.2.34.4.7 --- squid/src/structs.h 7 Oct 2005 03:23:11 -0000 1.48.2.34.4.6 +++ squid/src/structs.h 9 Oct 2005 15:47:15 -0000 1.48.2.34.4.7 @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.48.2.34.4.6 2005/10/07 03:23:11 adri Exp $ + * $Id: structs.h,v 1.48.2.34.4.7 2005/10/09 15:47:15 adri Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -1007,6 +1007,7 @@ MemBuf reply_hdr; int reply_hdr_state; int pending_read; + store_kick_type_t pending_kick; peer *peer; /* peer request made to */ int eof; /* reached end-of-object? */ request_t *orig_request;