** If you have a stat buffer on the file, pass it in, otherwise pass 0.
diff -ur thttpd-2.21b/thttpd.c thttpd-2.21b-cool/thttpd.c
--- thttpd-2.21b/thttpd.c Tue Apr 24 00:41:57 2001
-+++ thttpd-2.21b-cool/thttpd.c Thu May 15 18:38:35 2003
++++ thttpd-2.21b-cool/thttpd.c Thu May 15 18:51:28 2003
@@ -53,6 +53,10 @@
#endif
#include <unistd.h>
/* In lingering-close mode we just read and ignore bytes. An error
** or EOF ends things, otherwise we go until a timeout.
*/
-@@ -1569,6 +1728,61 @@
+@@ -1569,6 +1728,63 @@
}
+
+ n = read(hc->conn_fd, hc->read_buf + hc->read_idx,
+ hc->contentlength - (hc->read_idx - hc->checked_idx));
-+
++
+ if (n <= 0) {
+ if (errno == EAGAIN)
+ return;
+ clear_connection(c, tvP, 0);
+ return;
+ }
++
++ c->last_io = httpd_time_now;
+
+ hc->read_idx += n;
+
static int
check_throttles( connecttab* c )
{
-@@ -1635,23 +1849,18 @@
+@@ -1635,23 +1851,18 @@
static void
if ( c->wakeup_timer != (Timer*) 0 )
{
tmr_cancel( c->wakeup_timer );
-@@ -1669,13 +1878,36 @@
+@@ -1669,13 +1880,36 @@
** circumstances that make a lingering close necessary. If the flag
** isn't set we do the real close now.
*/
client_data.p = c;
c->linger_timer = tmr_create(
tvP, linger_clear_connection, client_data, LINGER_TIME * 1000L, 0 );
-@@ -1684,9 +1916,19 @@
+@@ -1684,9 +1918,19 @@
syslog( LOG_CRIT, "tmr_create(linger_clear_connection) failed" );
exit( 1 );
}
}
-@@ -1702,45 +1944,12 @@
+@@ -1702,45 +1946,12 @@
tmr_cancel( c->linger_timer );
c->linger_timer = 0;
}
static void
wakeup_connection( ClientData client_data, struct timeval* nowP )
-@@ -1783,6 +1992,43 @@
+@@ -1783,6 +1994,43 @@
}
#endif /* STATS_TIME */
/* Generate debugging statistics syslog messages for all packages. */
static void
-@@ -1826,3 +2072,41 @@
+@@ -1826,3 +2074,42 @@
stats_connections = stats_bytes = 0L;
stats_simultaneous = 0;
}
+ }
+ break;
+ case CNST_READING:
++ case CNST_READING_BODY:
+ checked++;
+ if ((now - c->last_io) > IDLE_READ_TIMELIMIT) {
+ clear_connection( c, nowP, 0 );