akosut 97/01/25 17:15:18
Modified: src CHANGES http_config.c http_core.c http_protocol.c httpd.h Log: Change KeepAlive semantics, add MaxKeepAliveRequests directives (NCSA-style). Change keep-alive defaults. Reviewed by: Dean Gaudet, Marc Slemko Revision Changes Path 1.136 +3 -0 apache/src/CHANGES Index: CHANGES =================================================================== RCS file: /export/home/cvs/apache/src/CHANGES,v retrieving revision 1.135 retrieving revision 1.136 diff -C3 -r1.135 -r1.136 *** CHANGES 1997/01/25 22:42:56 1.135 --- CHANGES 1997/01/26 01:15:11 1.136 *************** *** 1,5 **** --- 1,8 ---- Changes with Apache 1.2b5 + *) Change KeepAlive semantics (On|Off instead of a number), add + MaxKeepAliveRequests directive. [Alexei Kosut] + *) Various NeXT compilation patches, as well as a change in regex/regcomp.c since that file also used a NEXT define. [Andreas Koenig] 1.42 +6 -1 apache/src/http_config.c Index: http_config.c =================================================================== RCS file: /export/home/cvs/apache/src/http_config.c,v retrieving revision 1.41 retrieving revision 1.42 diff -C3 -r1.41 -r1.42 *** http_config.c 1997/01/20 04:28:07 1.41 --- http_config.c 1997/01/26 01:15:11 1.42 *************** *** 936,941 **** --- 936,942 ---- s->timeout = 0; s->keep_alive_timeout = 0; s->keep_alive = -1; + s->keep_alive_max = -1; /* start the list of addreses */ addrs = &s->addrs; while( hostname[0] ) { *************** *** 998,1003 **** --- 999,1007 ---- if (virt->keep_alive == -1) virt->keep_alive = main_server->keep_alive; + if (virt->keep_alive_max == -1) + virt->keep_alive_max = main_server->keep_alive_max; + if (virt->send_buffer_size == 0) virt->send_buffer_size = main_server->send_buffer_size; } *************** *** 1040,1046 **** s->access_confname = ACCESS_CONFIG_FILE; s->timeout = DEFAULT_TIMEOUT; s->keep_alive_timeout = DEFAULT_KEEPALIVE_TIMEOUT; ! s->keep_alive = DEFAULT_KEEPALIVE; s->next = NULL; s->addrs = pcalloc(p, sizeof (server_addr_rec)); s->addrs->host_addr.s_addr = htonl (INADDR_ANY); /* NOT virtual host; --- 1044,1051 ---- s->access_confname = ACCESS_CONFIG_FILE; s->timeout = DEFAULT_TIMEOUT; s->keep_alive_timeout = DEFAULT_KEEPALIVE_TIMEOUT; ! s->keep_alive_max = DEFAULT_KEEPALIVE; ! s->keep_alive = 1; s->next = NULL; s->addrs = pcalloc(p, sizeof (server_addr_rec)); s->addrs->host_addr.s_addr = htonl (INADDR_ANY); /* NOT virtual host; 1.61 +14 -2 apache/src/http_core.c Index: http_core.c =================================================================== RCS file: /export/home/cvs/apache/src/http_core.c,v retrieving revision 1.60 retrieving revision 1.61 diff -C3 -r1.60 -r1.61 *** http_core.c 1997/01/24 07:42:45 1.60 --- http_core.c 1997/01/26 01:15:12 1.61 *************** *** 899,905 **** } const char *set_keep_alive (cmd_parms *cmd, void *dummy, char *arg) { ! cmd->server->keep_alive = atoi (arg); return NULL; } --- 899,916 ---- } const char *set_keep_alive (cmd_parms *cmd, void *dummy, char *arg) { ! /* We've changed it to On/Off, but used to use numbers ! * so we accept anything but "Off" or "0" as "On" ! */ ! if (!strcasecmp(arg, "off") || !strcmp(arg, "0")) ! cmd->server->keep_alive = 0; ! else ! cmd->server->keep_alive = 1; ! return NULL; ! } ! ! const char *set_keep_alive_max (cmd_parms *cmd, void *dummy, char *arg) { ! cmd->server->keep_alive_max = atoi (arg); return NULL; } *************** *** 1172,1178 **** "The pathname the server can be reached at" }, { "Timeout", set_timeout, NULL, RSRC_CONF, TAKE1, "Timeout duration (sec)"}, { "KeepAliveTimeout", set_keep_alive_timeout, NULL, RSRC_CONF, TAKE1, "Keep-Alive timeout duration (sec)"}, ! { "KeepAlive", set_keep_alive, NULL, RSRC_CONF, TAKE1, "Maximum Keep-Alive requests per connection (0 to disable)" }, { "IdentityCheck", set_idcheck, NULL, RSRC_CONF|ACCESS_CONF, FLAG, "Enable identd (RFC931) user lookups - SLOW" }, { "ContentDigest", set_content_md5, NULL, RSRC_CONF|ACCESS_CONF|OR_AUTHCFG, FLAG, "whether or not to send a Content-MD5 header with each request" }, { "StartServers", set_daemons_to_start, NULL, RSRC_CONF, TAKE1, "Number of child processes launched at server startup" }, --- 1183,1190 ---- "The pathname the server can be reached at" }, { "Timeout", set_timeout, NULL, RSRC_CONF, TAKE1, "Timeout duration (sec)"}, { "KeepAliveTimeout", set_keep_alive_timeout, NULL, RSRC_CONF, TAKE1, "Keep-Alive timeout duration (sec)"}, ! { "MaxKeepAliveRequests", set_keep_alive_max, NULL, RSRC_CONF, TAKE1, "Maximum number of Keep-Alive requests per connection, or 0 for infinite" }, ! { "KeepAlive", set_keep_alive, NULL, RSRC_CONF, TAKE1, "Whether persistent connections should be On or Off" }, { "IdentityCheck", set_idcheck, NULL, RSRC_CONF|ACCESS_CONF, FLAG, "Enable identd (RFC931) user lookups - SLOW" }, { "ContentDigest", set_content_md5, NULL, RSRC_CONF|ACCESS_CONF|OR_AUTHCFG, FLAG, "whether or not to send a Content-MD5 header with each request" }, { "StartServers", set_daemons_to_start, NULL, RSRC_CONF, TAKE1, "Number of child processes launched at server startup" }, 1.93 +9 -4 apache/src/http_protocol.c Index: http_protocol.c =================================================================== RCS file: /export/home/cvs/apache/src/http_protocol.c,v retrieving revision 1.92 retrieving revision 1.93 diff -C3 -r1.92 -r1.93 *** http_protocol.c 1997/01/25 22:37:12 1.92 --- http_protocol.c 1997/01/26 01:15:13 1.93 *************** *** 213,219 **** if (r->connection->keepalive == -1) /* Did we get bad input? */ r->connection->keepalive = 0; ! else if ((r->server->keep_alive > r->connection->keepalives) && (r->server->keep_alive_timeout > 0) && (r->header_only || length || tenc || ((r->proto_num >= 1001) && (r->byterange > 1 || (r->chunked = 1)))) && --- 213,220 ---- if (r->connection->keepalive == -1) /* Did we get bad input? */ r->connection->keepalive = 0; ! else if (r->server->keep_alive && (!r->server->keep_alive_max || ! (r->server->keep_alive_max > r->connection->keepalives)) && (r->server->keep_alive_timeout > 0) && (r->header_only || length || tenc || ((r->proto_num >= 1001) && (r->byterange > 1 || (r->chunked = 1)))) && *************** *** 226,240 **** * length-delimited. It is not a bug, though it is annoying. */ char header[256]; ! int left = r->server->keep_alive - r->connection->keepalives; r->connection->keepalive = 1; r->connection->keepalives++; /* If they sent a Keep-Alive token, send one back */ if (ka_sent) { ! ap_snprintf(header, sizeof(header), "timeout=%d, max=%d", ! r->server->keep_alive_timeout, left); rputs("Connection: Keep-Alive\015\012", r); rvputs(r, "Keep-Alive: ", header, "\015\012", NULL); } --- 227,245 ---- * length-delimited. It is not a bug, though it is annoying. */ char header[256]; ! int left = r->server->keep_alive_max - r->connection->keepalives; r->connection->keepalive = 1; r->connection->keepalives++; /* If they sent a Keep-Alive token, send one back */ if (ka_sent) { ! if (r->server->keep_alive_max) ! ap_snprintf(header, sizeof(header), "timeout=%d, max=%d", ! r->server->keep_alive_timeout, left); ! else ! ap_snprintf(header, sizeof(header), "timeout=%d", ! r->server->keep_alive_timeout); rputs("Connection: Keep-Alive\015\012", r); rvputs(r, "Keep-Alive: ", header, "\015\012", NULL); } 1.80 +3 -2 apache/src/httpd.h Index: httpd.h =================================================================== RCS file: /export/home/cvs/apache/src/httpd.h,v retrieving revision 1.79 retrieving revision 1.80 diff -C3 -r1.79 -r1.80 *** httpd.h 1997/01/07 06:18:12 1.79 --- httpd.h 1997/01/26 01:15:14 1.80 *************** *** 187,193 **** #define DEFAULT_KEEPALIVE_TIMEOUT 15 /* The number of requests to entertain per connection */ ! #define DEFAULT_KEEPALIVE 5 /* The size of the server's internal read-write buffers */ #define IOBUFSIZE 8192 --- 187,193 ---- #define DEFAULT_KEEPALIVE_TIMEOUT 15 /* The number of requests to entertain per connection */ ! #define DEFAULT_KEEPALIVE 100 /* The size of the server's internal read-write buffers */ #define IOBUFSIZE 8192 *************** *** 594,600 **** server_addr_rec *addrs; int timeout; /* Timeout, in seconds, before we give up */ int keep_alive_timeout; /* Seconds we'll wait for another request */ ! int keep_alive; /* Maximum requests per connection */ int send_buffer_size; /* size of TCP send buffer (in bytes) */ char *path; /* Pathname for ServerPath */ --- 594,601 ---- server_addr_rec *addrs; int timeout; /* Timeout, in seconds, before we give up */ int keep_alive_timeout; /* Seconds we'll wait for another request */ ! int keep_alive_max; /* Maximum requests per connection */ ! int keep_alive; /* Use persistent connections? */ int send_buffer_size; /* size of TCP send buffer (in bytes) */ char *path; /* Pathname for ServerPath */