--------------------- PatchSet 7073 Date: 2005/10/05 14:54:00 Author: adri Branch: tidyup_deferred_reads Tag: (none) Log: Break out the read scheduling and cancelling. This will become more useful when we start starting/stopping IO based on client dataflow. Members: src/http.c:1.17.6.27.4.9->1.17.6.27.4.10 src/structs.h:1.48.2.34.4.4->1.48.2.34.4.5 Index: squid/src/http.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/http.c,v retrieving revision 1.17.6.27.4.9 retrieving revision 1.17.6.27.4.10 diff -u -r1.17.6.27.4.9 -r1.17.6.27.4.10 --- squid/src/http.c 5 Oct 2005 14:48:14 -0000 1.17.6.27.4.9 +++ squid/src/http.c 5 Oct 2005 14:54:00 -0000 1.17.6.27.4.10 @@ -1,6 +1,6 @@ /* - * $Id: http.c,v 1.17.6.27.4.9 2005/10/05 14:48:14 adri Exp $ + * $Id: http.c,v 1.17.6.27.4.10 2005/10/05 14:54:00 adri Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -550,6 +550,20 @@ return 1; } +void +httpReadSchedule(int fd, HttpStateData *httpState) +{ + httpState->pending_read = 1; + commSetSelect(fd, COMM_SELECT_READ, httpReadReply, httpState, 0); +} + +void +httpReadClear(int fd, HttpStateData *httpState) +{ + httpState->pending_read = 0; + commSetSelect(fd, COMM_SELECT_READ, NULL, NULL, 0); +} + /* This will be called when data is ready to be read from fd. Read until * error or connection closed. */ /* XXX this function is too long! */ @@ -568,6 +582,7 @@ delay_id delay_id; #endif + httpState->pending_read = 0; if (EBIT_TEST(entry->flags, ENTRY_ABORTED)) { comm_close(fd); return; @@ -602,7 +617,7 @@ if (len == 0) { /* Continue to read... */ /* Timeout NOT increased. This whitespace was from previous reply */ - commSetSelect(fd, COMM_SELECT_READ, httpReadReply, httpState, 0); + httpReadSchedule(fd, httpState); return; } } @@ -610,7 +625,7 @@ debug(50, 2) ("httpReadReply: FD %d: read failure: %s.\n", fd, xstrerror()); if (ignoreErrno(errno)) { - commSetSelect(fd, COMM_SELECT_READ, httpReadReply, httpState, 0); + httpReadSchedule(fd, httpState); } else { ErrorState *err; err = errorCon(ERR_READ_ERROR, HTTP_BAD_GATEWAY); @@ -732,7 +747,7 @@ /* yes we have to clear all these! */ commSetDefer(fd, NULL, NULL); commSetTimeout(fd, -1, NULL, NULL); - commSetSelect(fd, COMM_SELECT_READ, NULL, NULL, 0); + httpReadClear(fd, httpState); #if DELAY_POOLS delayClearNoDelay(fd); #endif @@ -755,7 +770,7 @@ } else { commSetTimeout(fd, Config.Timeout.read, NULL, NULL); } - commSetSelect(fd, COMM_SELECT_READ, httpReadReply, httpState, 0); + httpReadSchedule(fd, httpState); return; case -1: /* Server is nasty on us. Shut down */ @@ -1074,7 +1089,7 @@ /* Schedule read reply. (but no timeout set until request fully sent) */ commSetTimeout(fd, Config.Timeout.lifetime, httpTimeout, httpState); - commSetSelect(fd, COMM_SELECT_READ, httpReadReply, httpState, 0); + httpReadSchedule(fd, httpState); if (httpState->orig_request->body_reader) sendHeaderDone = httpSendRequestEntry; Index: squid/src/structs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/structs.h,v retrieving revision 1.48.2.34.4.4 retrieving revision 1.48.2.34.4.5 diff -u -r1.48.2.34.4.4 -r1.48.2.34.4.5 --- squid/src/structs.h 2 Oct 2005 09:45:28 -0000 1.48.2.34.4.4 +++ squid/src/structs.h 5 Oct 2005 14:54:00 -0000 1.48.2.34.4.5 @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.48.2.34.4.4 2005/10/02 09:45:28 adri Exp $ + * $Id: structs.h,v 1.48.2.34.4.5 2005/10/05 14:54:00 adri Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -1006,6 +1006,7 @@ request_t *request; MemBuf reply_hdr; int reply_hdr_state; + int pending_read; peer *peer; /* peer request made to */ int eof; /* reached end-of-object? */ request_t *orig_request;