diff -urN squid-2.5.STABLE9.orig/src/http.c squid-2.5.STABLE9-epoll/src/http.c --- squid-2.5.STABLE9.orig/src/http.c Tue Mar 15 16:17:03 2005 +++ squid-2.5.STABLE9-epoll/src/http.c Thu Mar 17 07:42:52 2005 @@ -579,7 +579,24 @@ comm_close(fd); return; } - /* check if we want to defer reading */ + /* check if we want to defer reading (this stops squid from using too much memory for in-transit objects */ + /* If the object has no swapout entry, and the memory foortprint is too big */ + if( (!(entry->mem_obj->swapout.sio)) && ((entry->mem_obj->inmem_hi - entry->mem_obj->inmem_lo) > READ_AHEAD_GAP) ) { + /* Flush written data out of memory */ + storeSwapOut(entry); + + if((entry->mem_obj->inmem_hi - entry->mem_obj->inmem_lo) > READ_AHEAD_GAP) { + /* Wait for more data or EOF condition */ + if (httpState->flags.keepalive_broken) { + commSetTimeout(fd, 10, NULL, NULL); + } else { + commSetTimeout(fd, Config.Timeout.read, NULL, NULL); + } + commSetSelect(fd, COMM_SELECT_READ, httpReadReply, httpState, 0); + commSetDefer(fd, NULL, NULL); + return; + } + } errno = 0; read_sz = SQUID_TCP_SO_RCVBUF; #if DELAY_POOLS