/* Done with an mmap()ed area that was returned by mmc_map().
** If you have a stat buffer on the file, pass it in, otherwise pass 0.
-diff -ur thttpd-2.21b/php_makefile thttpd-2.21b-cool/php_makefile
---- thttpd-2.21b/php_makefile Wed Apr 16 14:53:42 2003
-+++ thttpd-2.21b-cool/php_makefile Wed Apr 16 09:24:09 2003
-@@ -1,3 +1,3 @@
- PHP_LIBS = -L. -lphp4 -lcrypt -lcrypt -lresolv -lm -ldl -lnsl -lcrypt -lcrypt
- PHP_LDFLAGS = -rdynamic
--PHP_CFLAGS = -DPHP_ATOM_INC -I/home/sas/opt-th/php/include -I/home/sas/opt-th/php/main -I/home/sas/src/php4 -I/home/sas/opt-th/thttpd-2.21b -I/home/sas/opt-th/php/Zend -I/home/sas/src/php4/main -I/home/sas/src/php4/Zend -I/home/sas/src/php4/TSRM -I/home/sas/opt-th/php/TSRM -O0 -g -I/home/sas/opt-th/php/TSRM
-+PHP_CFLAGS = -DPHP_ATOM_INC -I/home/sas/opt-th/php/include -I/home/sas/opt-th/php/main -I/home/sas/src/php4 -I/home/sas/opt-th/thttpd-2.21b -I/home/sas/opt-th/php/Zend -I/home/sas/src/php4/main -I/home/sas/src/php4/Zend -I/home/sas/src/php4/TSRM -I/home/sas/opt-th/php/TSRM -O2 -march=i586 -I/home/sas/opt-th/php/TSRM
diff -ur thttpd-2.21b/thttpd.c thttpd-2.21b-cool/thttpd.c
--- thttpd-2.21b/thttpd.c Wed Apr 16 15:42:14 2003
-+++ thttpd-2.21b-cool/thttpd.c Wed Apr 16 10:31:16 2003
++++ thttpd-2.21b-cool/thttpd.c Mon Apr 21 03:06:13 2003
@@ -53,6 +53,10 @@
#endif
#include <unistd.h>
while ( ( ! terminate ) || numconnects > 0 )
{
/* Do the fd watch. */
-@@ -565,16 +610,10 @@
+@@ -530,6 +575,7 @@
+ exit( 1 );
+ }
+ (void) gettimeofday( &tv, (struct timezone*) 0 );
++ httpd_time_now = tv.tv_sec;
+ if ( num_ready == 0 )
+ {
+ /* No fd's are ready - run the timers. */
+@@ -565,16 +611,10 @@
c = (connecttab*) fdwatch_get_client_data( ridx );
if ( c == (connecttab*) 0 )
continue;
}
tmr_run( &tv );
-@@ -627,6 +666,8 @@
+@@ -627,6 +667,8 @@
#else /* CGI_PATTERN */
cgi_pattern = (char*) 0;
#endif /* CGI_PATTERN */
url_pattern = (char*) 0;
no_empty_referers = 0;
local_pattern = (char*) 0;
-@@ -833,6 +874,16 @@
+@@ -833,6 +875,16 @@
value_required( name, value );
cgi_pattern = e_strdup( value );
}
else if ( strcasecmp( name, "urlpat" ) == 0 )
{
value_required( name, value );
-@@ -1196,8 +1247,10 @@
+@@ -1196,8 +1248,10 @@
logstats( &tv );
for ( cnum = 0; cnum < maxconnects; ++cnum )
{
if ( connects[cnum].hc != (httpd_conn*) 0 )
{
httpd_destroy_conn( connects[cnum].hc );
-@@ -1214,6 +1267,7 @@
+@@ -1214,6 +1268,7 @@
}
mmc_destroy();
tmr_destroy();
free( (void*) connects );
if ( throttles != (throttletab*) 0 )
free( (void*) throttles );
-@@ -1234,7 +1288,7 @@
+@@ -1234,7 +1289,7 @@
for (;;)
{
/* Is there room in the connection table? */
{
/* Out of connection slots. Run the timers, then the
** existing connections, and maybe we'll free up a slot
-@@ -1245,10 +1299,10 @@
+@@ -1245,10 +1300,10 @@
return 0;
}
/* Find a free connection entry. */
/* Make the httpd_conn if necessary. */
if ( c->hc == (httpd_conn*) 0 )
{
-@@ -1267,24 +1321,18 @@
+@@ -1267,24 +1322,18 @@
{
case GC_FAIL:
case GC_NO_MORE:
/* Set the connection file descriptor to no-delay mode. */
httpd_set_ndelay( c->hc->conn_fd );
-@@ -1297,12 +1345,79 @@
+@@ -1297,12 +1346,79 @@
}
}
httpd_conn* hc = c->hc;
/* Is there room in our buffer to read more bytes? */
-@@ -1311,7 +1426,7 @@
+@@ -1311,7 +1427,7 @@
if ( hc->read_size > 5000 )
{
httpd_send_err( hc, 400, httpd_err400title, "", httpd_err400form, "" );
return;
}
httpd_realloc_str(
-@@ -1327,14 +1442,53 @@
+@@ -1327,14 +1443,53 @@
** EWOULDBLOCK; however, this apparently can happen if a packet gets
** garbled.
*/
/* Do we have a complete request yet? */
switch ( httpd_got_request( hc ) )
{
-@@ -1342,14 +1496,14 @@
+@@ -1342,14 +1497,14 @@
return;
case GR_BAD_REQUEST:
httpd_send_err( hc, 400, httpd_err400title, "", httpd_err400form, "" );
return;
}
-@@ -1358,18 +1512,28 @@
+@@ -1358,18 +1513,28 @@
{
httpd_send_err(
hc, 503, httpd_err503title, "", httpd_err503form, hc->encodedurl );
/* Fill in bytes_to_send. */
if ( hc->got_range )
{
-@@ -1384,37 +1548,25 @@
+@@ -1384,37 +1549,25 @@
{
/* No file address means someone else is handling it. */
c->bytes_sent = hc->bytes_sent;
static void
handle_send( connecttab* c, struct timeval* tvP )
{
-@@ -1443,6 +1595,9 @@
+@@ -1443,6 +1596,9 @@
iv[1].iov_base = &(hc->file_address[c->bytes_sent]);
iv[1].iov_len = MIN( c->bytes_to_send - c->bytes_sent, c->limit );
sz = writev( hc->conn_fd, iv, 2 );
}
if ( sz == 0 ||
-@@ -1486,12 +1641,12 @@
+@@ -1486,12 +1642,12 @@
*/
if ( errno != EPIPE && errno != EINVAL && errno != ECONNRESET )
syslog( LOG_ERR, "write - %m sending %.80s", hc->encodedurl );
/* Was this a headers + file writev()? */
if ( hc->responselen > 0 )
{
-@@ -1500,7 +1655,7 @@
+@@ -1500,7 +1656,7 @@
{
/* Yes; move the unwritten part to the front of the buffer. */
int newlen = hc->responselen - sz;
hc->responselen = newlen;
sz = 0;
}
-@@ -1519,7 +1674,7 @@
+@@ -1519,7 +1675,7 @@
if ( c->bytes_sent >= c->bytes_to_send )
{
/* This conection is finished! */
return;
}
-@@ -1560,6 +1715,9 @@
+@@ -1560,6 +1716,9 @@
char buf[1024];
int r;
/* In lingering-close mode we just read and ignore bytes. An error
** or EOF ends things, otherwise we go until a timeout.
*/
-@@ -1569,6 +1727,61 @@
+@@ -1569,6 +1728,61 @@
}
static int
check_throttles( connecttab* c )
{
-@@ -1635,23 +1848,18 @@
+@@ -1635,23 +1849,18 @@
static void
if ( c->wakeup_timer != (Timer*) 0 )
{
tmr_cancel( c->wakeup_timer );
-@@ -1669,13 +1877,36 @@
+@@ -1669,13 +1878,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 +1915,19 @@
+@@ -1684,9 +1916,19 @@
syslog( LOG_CRIT, "tmr_create(linger_clear_connection) failed" );
exit( 1 );
}
}
-@@ -1702,45 +1943,12 @@
+@@ -1702,45 +1944,12 @@
tmr_cancel( c->linger_timer );
c->linger_timer = 0;
}
static void
wakeup_connection( ClientData client_data, struct timeval* nowP )
-@@ -1783,6 +1991,43 @@
+@@ -1783,6 +1992,43 @@
}
#endif /* STATS_TIME */
/* Generate debugging statistics syslog messages for all packages. */
static void
-@@ -1826,3 +2071,41 @@
+@@ -1826,3 +2072,41 @@
stats_connections = stats_bytes = 0L;
stats_simultaneous = 0;
}