diff -u -r ../apache_1.3.20/src/include/http_protocol.h ./src/include/http_protocol.h --- ../apache_1.3.20/src/include/http_protocol.h Mon Jan 15 12:04:35 2001 +++ ./src/include/http_protocol.h Mon Jun 11 17:12:57 2001 @@ -88,6 +88,10 @@ API_EXPORT(void) ap_send_http_header(request_rec *l); +/* Maybe set Scavenger service. */ + +API_EXPORT(void) ap_maybe_start_scavenging(request_rec *r); + /* Send the response to special method requests */ API_EXPORT(int) ap_send_http_trace(request_rec *r); diff -u -r ../apache_1.3.20/src/include/httpd.h ./src/include/httpd.h --- ../apache_1.3.20/src/include/httpd.h Tue May 15 11:58:46 2001 +++ ./src/include/httpd.h Mon Jun 11 15:34:36 2001 @@ -321,6 +321,16 @@ #endif /* + * QBSS (QBone Scavenger Service) TOS value. + * It's officially DSCP 001000, which corresponds to TOS 0x20 for + * marking purposes. + * See http://qbone.internet2.edu/qbss/ for more QBSS info. + */ +#ifndef TOS_SCAVENGER +#define TOS_SCAVENGER 0x20 +#endif + +/* * Special Apache error codes. These are basically used * in http_main.c so we can keep track of various errors. * @@ -958,6 +968,10 @@ 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) */ + int start_scavenging_from_size; + /* For files this large or larger, turn on + Scavenger service (DSCP 001000). Set + to 0 to disable. */ char *path; /* Pathname for ServerPath */ int pathlen; /* Length of path */ diff -u -r ../apache_1.3.20/src/main/http_config.c ./src/main/http_config.c --- ../apache_1.3.20/src/main/http_config.c Tue Jan 23 21:11:09 2001 +++ ./src/main/http_config.c Mon Jun 11 17:07:47 2001 @@ -1482,6 +1482,10 @@ if (virt->send_buffer_size == 0) virt->send_buffer_size = main_server->send_buffer_size; + if (virt->start_scavenging_from_size == 0) + virt->start_scavenging_from_size = + main_server->start_scavenging_from_size; + /* XXX: this is really something that should be dealt with by a * post-config api phase */ ap_core_reorder_directories(p, virt); diff -u -r ../apache_1.3.20/src/main/http_core.c ./src/main/http_core.c --- ../apache_1.3.20/src/main/http_core.c Fri Mar 9 05:10:25 2001 +++ ./src/main/http_core.c Mon Jun 11 16:55:32 2001 @@ -2021,6 +2021,22 @@ return NULL; } +static const char * +set_start_scavenging_from_size(cmd_parms *cmd, void *dummy, char *arg) +{ + int s = atoi(arg); + const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); + if (err != NULL) { + return err; + } + + if (s < 0) { + return "StartScavengingFromSize must be non-negative (0 to disable)"; + } + cmd->server->start_scavenging_from_size = s; + return NULL; +} + static const char *set_user(cmd_parms *cmd, void *dummy, char *arg) { #ifdef WIN32 @@ -3148,6 +3164,8 @@ "A port number or a numeric IP address and a port number"}, { "SendBufferSize", set_send_buffer_size, NULL, RSRC_CONF, TAKE1, "Send buffer size in bytes"}, +{ "StartScavengingFromSize", set_start_scavenging_from_size, NULL, RSRC_CONF, + TAKE1, "File size starting from which Scavenger service will be used"}, { "AddModule", add_module_command, NULL, RSRC_CONF, ITERATE, "The name of a module" }, { "ClearModuleList", clear_module_list_command, NULL, RSRC_CONF, NO_ARGS, @@ -3636,6 +3654,8 @@ rangestatus = ap_set_byterange(r); ap_send_http_header(r); + /* It makes sense to set scavenger only after the headers are sent. */ + ap_maybe_start_scavenging(r); if (!r->header_only) { if (!rangestatus) { @@ -3682,6 +3702,7 @@ rangestatus = ap_set_byterange(r); ap_send_http_header(r); + ap_maybe_start_scavenging(r); if (!r->header_only) { if (!rangestatus) { diff -u -r ../apache_1.3.20/src/main/http_protocol.c ./src/main/http_protocol.c --- ../apache_1.3.20/src/main/http_protocol.c Fri Mar 9 05:10:26 2001 +++ ./src/main/http_protocol.c Mon Jun 11 18:05:12 2001 @@ -1809,6 +1809,18 @@ #endif /*CHARSET_EBCDIC*/ } +/* Possibly turn on QBSS marking on the client connection. */ +API_EXPORT(void) ap_maybe_start_scavenging(request_rec *r) +{ + int qbss = TOS_SCAVENGER; + if (r->server->start_scavenging_from_size + && r->server->start_scavenging_from_size < r->finfo.st_size) { + /* If it fails, we just go on as if nothing has happened. */ + setsockopt(r->connection->client->fd, IPPROTO_IP, IP_TOS, + (char*) &qbss, sizeof qbss); + } +} + /* finalize_request_protocol is called at completion of sending the * response. It's sole purpose is to send the terminating protocol * information for any wrappers around the response message body