jim 98/08/10 17:09:49
Modified: src CHANGES Configuration.tmpl src/include http_conf_globals.h scoreboard.h src/main http_config.c http_core.c http_main.c http_request.c src/modules/standard mod_status.c Log: Make "extended" status information (which used to be compile-time by defining STATUS) now run-time using the ExtendedStatus directive. Docs to be changed soon. Revision Changes Path 1.1017 +4 -0 apache-1.3/src/CHANGES Index: CHANGES =================================================================== RCS file: /export/home/cvs/apache-1.3/src/CHANGES,v retrieving revision 1.1016 retrieving revision 1.1017 diff -u -r1.1016 -r1.1017 --- CHANGES 1998/08/10 17:11:16 1.1016 +++ CHANGES 1998/08/11 00:09:41 1.1017 @@ -1,5 +1,9 @@ Changes with Apache 1.3.2 + *) STATUS is no longer available. Full status information now + run-time configurable using the ExtendedStatus directive. + [Jim Jagielski] + *) SECURITY: Eliminate O(n^2) space DoS attacks (and other O(n^2) cpu time attacks) in header parsing. [Dean Gaudet] 1.109 +3 -10 apache-1.3/src/Configuration.tmpl Index: Configuration.tmpl =================================================================== RCS file: /export/home/cvs/apache-1.3/src/Configuration.tmpl,v retrieving revision 1.108 retrieving revision 1.109 diff -u -r1.108 -r1.109 --- Configuration.tmpl 1998/08/03 08:44:03 1.108 +++ Configuration.tmpl 1998/08/11 00:09:42 1.109 @@ -118,7 +118,7 @@ # functions. The format is: Rule RULE=value # # At present, only the following RULES are known: WANTHSREGEX, SOCKS4, -# SOCKS5, STATUS, IRIXNIS, IRIXN32 and PARANOID. +# SOCKS5, IRIXNIS, IRIXN32 and PARANOID. # # For all Rules, if set to "yes", then Configure knows we want that # capability and does what is required to add it in. If set to "default" @@ -135,12 +135,6 @@ # location to EXTRA_LIBS, otherwise Configure will assume # "-L/usr/local/lib -lsocks5" # -# STATUS: -# If Configure determines that you are using the status_module, -# it will automatically enable full status information if set -# to 'yes'. If the status module is not included, having STATUS -# set to 'yes' has no impact. -# # IRIXNIS: # Only takes effect if Configure determines that you are running # SGI IRIX. If you are using a (ancient) 4.x version of IRIX, you @@ -161,7 +155,6 @@ # actually print-out the code that the modules execute # -Rule STATUS=yes Rule SOCKS4=no Rule SOCKS5=no Rule IRIXNIS=no @@ -249,8 +242,8 @@ ## ## The status module allows the server to display current details about ## how well it is performing and what it is doing. Consider also enabling -## STATUS=yes (see the Rules section near the start of this file) to allow -## full status information. Check conf/access.conf on how to enable this. +## the 'ExtendedStatus On' directive to allow full status information. +## Please note that doing so can result in a palpable performance hit. # AddModule modules/standard/mod_status.o 1.33 +1 -0 apache-1.3/src/include/http_conf_globals.h Index: http_conf_globals.h =================================================================== RCS file: /export/home/cvs/apache-1.3/src/include/http_conf_globals.h,v retrieving revision 1.32 retrieving revision 1.33 diff -u -r1.32 -r1.33 --- http_conf_globals.h 1998/06/16 03:37:24 1.32 +++ http_conf_globals.h 1998/08/11 00:09:43 1.33 @@ -85,6 +85,7 @@ extern MODULE_VAR_EXPORT int ap_suexec_enabled; extern int ap_listenbacklog; extern int ap_dump_settings; +extern int ap_extended_status; extern char *ap_pid_fname; extern char *ap_scoreboard_fname; 1.41 +0 -2 apache-1.3/src/include/scoreboard.h Index: scoreboard.h =================================================================== RCS file: /export/home/cvs/apache-1.3/src/include/scoreboard.h,v retrieving revision 1.40 retrieving revision 1.41 diff -u -r1.40 -r1.41 --- scoreboard.h 1998/05/03 17:31:10 1.40 +++ scoreboard.h 1998/08/11 00:09:43 1.41 @@ -109,7 +109,6 @@ unsigned short timeout_len; /* length of the timeout */ #endif unsigned char status; -#if defined(STATUS) unsigned long access_count; unsigned long bytes_served; unsigned long my_access_count; @@ -132,7 +131,6 @@ char client[32]; /* Keep 'em small... */ char request[64]; /* We just want an idea... */ char vhost[32]; /* What virtual host is being accessed? */ -#endif } short_score; typedef struct { 1.122 +1 -0 apache-1.3/src/main/http_config.c Index: http_config.c =================================================================== RCS file: /export/home/cvs/apache-1.3/src/main/http_config.c,v retrieving revision 1.121 retrieving revision 1.122 diff -u -r1.121 -r1.122 --- http_config.c 1998/08/10 04:16:14 1.121 +++ http_config.c 1998/08/11 00:09:44 1.122 @@ -1390,6 +1390,7 @@ ap_bind_address.s_addr = htonl(INADDR_ANY); ap_listeners = NULL; ap_listenbacklog = DEFAULT_LISTENBACKLOG; + ap_extended_status = 0; /* Global virtual host hash bucket pointers. Init to null. */ ap_init_vhost_config(p); 1.221 +22 -0 apache-1.3/src/main/http_core.c Index: http_core.c =================================================================== RCS file: /export/home/cvs/apache-1.3/src/main/http_core.c,v retrieving revision 1.220 retrieving revision 1.221 diff -u -r1.220 -r1.221 --- http_core.c 1998/08/10 14:37:06 1.220 +++ http_core.c 1998/08/11 00:09:44 1.221 @@ -2313,6 +2313,26 @@ return NULL; } +/* + * Here, and not in the status module, because we want this GLOBAL_ONLY. + * Note that if enabled, there is a nasty performance hit, even if + * the status module is NOT loaded. + */ +static const char *set_extended_status(cmd_parms *cmd, void *dummy, char *arg) +{ + const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); + if (err != NULL) { + return err; + } + if (!strcasecmp(arg, "off") || !strcmp(arg, "0")) { + ap_extended_status = 0; + } + else { + ap_extended_status = 1; + } + return NULL; +} + static const char *set_limit_req_body(cmd_parms *cmd, core_dir_config *conf, char *arg) { @@ -2531,6 +2551,8 @@ #endif { "ServerTokens", set_serv_tokens, NULL, RSRC_CONF, TAKE1, "Determine tokens displayed in the Server: header - Min(imal), OS or Full" }, +{ "ExtendedStatus", set_extended_status, NULL, RSRC_CONF, TAKE1, + "\On\" to enable extended status information, \"Off\" to disable" }, { "LimitRequestBody", set_limit_req_body, (void*)XtOffsetOf(core_dir_config, limit_req_body), RSRC_CONF|ACCESS_CONF|OR_ALL, TAKE1, 1.381 +34 -40 apache-1.3/src/main/http_main.c Index: http_main.c =================================================================== RCS file: /export/home/cvs/apache-1.3/src/main/http_main.c,v retrieving revision 1.380 retrieving revision 1.381 diff -u -r1.380 -r1.381 --- http_main.c 1998/08/07 15:35:49 1.380 +++ http_main.c 1998/08/11 00:09:45 1.381 @@ -247,6 +247,7 @@ int ap_suexec_enabled = 0; int ap_listenbacklog; int ap_dump_settings; +int ap_extended_status = 0; /* * The max child slot ever assigned, preserved across restarts. Necessary @@ -352,7 +353,7 @@ /* * This routine is called when the pconf pool is vacuumed. It resets the * server version string to a known value and [re]enables modifications - * (which are disabled by configuration completion). + * (which are disabled by configuration completion). */ static void reset_version(void *dummy) { @@ -1961,40 +1962,39 @@ ++ss->cur_vtime; #endif -#if defined(STATUS) + if (ap_extended_status) { #ifndef OPTIMIZE_TIMEOUTS - ss->last_used = time(NULL); + ss->last_used = time(NULL); #endif - if (status == SERVER_READY || status == SERVER_DEAD) { - /* - * Reset individual counters - */ - if (status == SERVER_DEAD) { - ss->my_access_count = 0L; - ss->my_bytes_served = 0L; + if (status == SERVER_READY || status == SERVER_DEAD) { + /* + * Reset individual counters + */ + if (status == SERVER_DEAD) { + ss->my_access_count = 0L; + ss->my_bytes_served = 0L; + } + ss->conn_count = (unsigned short) 0; + ss->conn_bytes = (unsigned long) 0; } - ss->conn_count = (unsigned short) 0; - ss->conn_bytes = (unsigned long) 0; - } - if (r) { - conn_rec *c = r->connection; - ap_cpystrn(ss->client, ap_get_remote_host(c, r->per_dir_config, - REMOTE_NOLOOKUP), sizeof(ss->client)); - if (r->the_request == NULL) { - ap_cpystrn(ss->request, "NULL", sizeof(ss->request)); - } else if (r->parsed_uri.password == NULL) { - ap_cpystrn(ss->request, r->the_request, sizeof(ss->request)); - } else { - /* Don't reveal the password in the server-status view */ - ap_cpystrn(ss->request, ap_pstrcat(r->pool, r->method, " ", - ap_unparse_uri_components(r->pool, &r->parsed_uri, UNP_OMITPASSWORD), - r->assbackwards ? NULL : " ", r->protocol, NULL), - sizeof(ss->request)); + if (r) { + conn_rec *c = r->connection; + ap_cpystrn(ss->client, ap_get_remote_host(c, r->per_dir_config, + REMOTE_NOLOOKUP), sizeof(ss->client)); + if (r->the_request == NULL) { + ap_cpystrn(ss->request, "NULL", sizeof(ss->request)); + } else if (r->parsed_uri.password == NULL) { + ap_cpystrn(ss->request, r->the_request, sizeof(ss->request)); + } else { + /* Don't reveal the password in the server-status view */ + ap_cpystrn(ss->request, ap_pstrcat(r->pool, r->method, " ", + ap_unparse_uri_components(r->pool, &r->parsed_uri, UNP_OMITPASSWORD), + r->assbackwards ? NULL : " ", r->protocol, NULL), + sizeof(ss->request)); + } + ap_cpystrn(ss->vhost, r->server->server_hostname, sizeof(ss->vhost)); } - ap_cpystrn(ss->vhost, r->server->server_hostname, sizeof(ss->vhost)); } -#endif - put_scoreboard_info(child_num, ss); return old_status; @@ -2010,7 +2010,6 @@ #endif } -#if defined(STATUS) void ap_time_process_request(int child_num, int status) { short_score *ss; @@ -2079,9 +2078,6 @@ put_scoreboard_info(child_num, ss); } -#endif - - static int find_child_by_pid(int pid) { int i; @@ -3705,9 +3701,8 @@ if (r->status == HTTP_OK) ap_process_request(r); -#if defined(STATUS) - increment_counts(my_child_num, r); -#endif + if(ap_extended_status) + increment_counts(my_child_num, r); if (!current_conn->keepalive || current_conn->aborted) break; @@ -4787,9 +4782,8 @@ if (r->status == HTTP_OK) ap_process_request(r); -#if defined(STATUS) - increment_counts(child_num, r); -#endif + if (ap_extended_status) + increment_counts(child_num, r); if (!current_conn->keepalive || current_conn->aborted) break; 1.130 +5 -6 apache-1.3/src/main/http_request.c Index: http_request.c =================================================================== RCS file: /export/home/cvs/apache-1.3/src/main/http_request.c,v retrieving revision 1.129 retrieving revision 1.130 diff -u -r1.129 -r1.130 --- http_request.c 1998/08/09 14:33:11 1.129 +++ http_request.c 1998/08/11 00:09:46 1.130 @@ -71,6 +71,7 @@ #include "http_request.h" #include "http_core.h" #include "http_protocol.h" +#include "http_conf_globals.h" /* for ap_extended_status */ #include "http_log.h" #include "http_main.h" #include "scoreboard.h" @@ -1182,9 +1183,8 @@ { int old_stat; -#ifdef STATUS - ap_time_process_request(r->connection->child_num, START_PREQUEST); -#endif + if (ap_extended_status) + ap_time_process_request(r->connection->child_num, START_PREQUEST); process_request_internal(r); @@ -1202,9 +1202,8 @@ ap_log_transaction(r); (void) ap_update_child_status(r->connection->child_num, old_stat, r); -#ifdef STATUS - ap_time_process_request(r->connection->child_num, STOP_PREQUEST); -#endif + if (ap_extended_status) + ap_time_process_request(r->connection->child_num, STOP_PREQUEST); } static table *rename_original_env(pool *p, table *t) 1.93 +232 -240 apache-1.3/src/modules/standard/mod_status.c Index: mod_status.c =================================================================== RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_status.c,v retrieving revision 1.92 retrieving revision 1.93 diff -u -r1.92 -r1.93 --- mod_status.c 1998/08/06 17:42:51 1.92 +++ mod_status.c 1998/08/11 00:09:48 1.93 @@ -91,27 +91,15 @@ * piece in short reports [Ben Laurie] * 21.5.96 Additional Status codes (DNS and LOGGING only enabled if * extended STATUS is enabled) [George Burgyan/Jim J.] + * 10.8.98 Allow for extended status info at runtime (no more STATUS) + * [Jim J.] */ -/* - * Module definition information - the part between the -START and -END - * lines below is used by Configure. This could be stored in a separate - * instead. - * - * MODULE-DEFINITION-START - * Name: status_module - * ConfigStart - if [ "$RULE_STATUS" = "yes" ]; then - CFLAGS="$CFLAGS -DSTATUS" - fi - * ConfigEnd - * MODULE-DEFINITION-END - */ - #include "httpd.h" #include "http_config.h" #include "http_core.h" #include "http_protocol.h" +#include "http_conf_globals.h" /* for ap_extended_status */ #include "http_main.h" #include "util_script.h" #include <time.h> @@ -142,9 +130,7 @@ module MODULE_VAR_EXPORT status_module; -#ifdef STATUS /* Format the number of bytes nicely */ - static void format_byte_out(request_rec *r, unsigned long bytes) { if (bytes < (5 * KBYTE)) @@ -167,8 +153,6 @@ ap_rprintf(r, "%.1f GB", (float) kbytes / MBYTE); } -#endif - static void show_time(request_rec *r, time_t tsecs) { long days, hrs, mins, secs; @@ -222,7 +206,6 @@ int i, res; int ready = 0; int busy = 0; -#if defined(STATUS) unsigned long count = 0; unsigned long lres, bytes; unsigned long my_lres, my_bytes, conn_bytes; @@ -235,7 +218,6 @@ #elif !defined(NO_TIMES) float tick = sysconf(_SC_CLK_TCK); #endif -#endif /* STATUS */ int short_report = 0; int no_table_report = 0; short_score score_record; @@ -268,10 +250,12 @@ switch (status_options[i].id) { case STAT_OPT_REFRESH: if (*(loc + strlen(status_options[i].form_data_str)) == '=') - ap_table_set(r->headers_out, status_options[i].hdr_out_str, - loc + strlen(status_options[i].hdr_out_str) + 1); + ap_table_set(r->headers_out, + status_options[i].hdr_out_str, + loc + strlen(status_options[i].hdr_out_str) + 1); else - ap_table_set(r->headers_out, status_options[i].hdr_out_str, "1"); + ap_table_set(r->headers_out, + status_options[i].hdr_out_str, "1"); break; case STAT_OPT_NOTABLE: no_table_report = 1; @@ -302,24 +286,24 @@ ready++; else if (res != SERVER_DEAD) busy++; -#if defined(STATUS) - lres = score_record.access_count; - bytes = score_record.bytes_served; - if (lres != 0 || (res != SERVER_READY && res != SERVER_DEAD)) { + if (ap_extended_status) { + lres = score_record.access_count; + bytes = score_record.bytes_served; + if (lres != 0 || (res != SERVER_READY && res != SERVER_DEAD)) { #ifndef NO_TIMES - tu += score_record.times.tms_utime; - ts += score_record.times.tms_stime; - tcu += score_record.times.tms_cutime; - tcs += score_record.times.tms_cstime; + tu += score_record.times.tms_utime; + ts += score_record.times.tms_stime; + tcu += score_record.times.tms_cutime; + tcs += score_record.times.tms_cstime; #endif /* NO_TIMES */ - count += lres; - bcount += bytes; - if (bcount >= KBYTE) { - kbcount += (bcount >> 10); - bcount = bcount & 0x3ff; + count += lres; + bcount += bytes; + if (bcount >= KBYTE) { + kbcount += (bcount >> 10); + bcount = bcount & 0x3ff; + } } } -#endif /* STATUS */ } up_time = nowtime - ap_restart_time; @@ -330,72 +314,79 @@ ap_rputs("<HTML><HEAD>\n<TITLE>Apache Status</TITLE>\n</HEAD><BODY>\n", r); ap_rputs("<H1>Apache Server Status for ", r); ap_rvputs(r, ap_get_server_name(r), "</H1>\n\n", NULL); - ap_rvputs(r, "Server Version: ", ap_get_server_version(), "<br>\n", - NULL); - ap_rvputs(r, "Server Built: ", ap_get_server_built(), "<br>\n<hr>\n", - NULL); - ap_rvputs(r, "Current Time: ", ap_ht_time(r->pool, nowtime, DEFAULT_TIME_FORMAT, 0), - "<br>\n", NULL); - ap_rvputs(r, "Restart Time: ", ap_ht_time(r->pool, ap_restart_time, DEFAULT_TIME_FORMAT, 0), - "<br>\n", NULL); + ap_rvputs(r, "Server Version: ", + ap_get_server_version(), "<br>\n", NULL); + ap_rvputs(r, "Server Built: ", + ap_get_server_built(), "<br>\n<hr>\n", NULL); + ap_rvputs(r, "Current Time: ", + ap_ht_time(r->pool, nowtime, DEFAULT_TIME_FORMAT, 0), "<br>\n", NULL); + ap_rvputs(r, "Restart Time: ", + ap_ht_time(r->pool, ap_restart_time, DEFAULT_TIME_FORMAT, 0), + "<br>\n", NULL); ap_rputs("Server uptime: ", r); show_time(r, up_time); ap_rputs("<br>\n", r); } -#if defined(STATUS) - if (short_report) { - ap_rprintf(r, "Total Accesses: %lu\nTotal kBytes: %lu\n", count, kbcount); + if (ap_extended_status) { + if (short_report) { + ap_rprintf(r, "Total Accesses: %lu\nTotal kBytes: %lu\n", + count, kbcount); #ifndef NO_TIMES - /* Allow for OS/2 not having CPU stats */ - if (ts || tu || tcu || tcs) - ap_rprintf(r, "CPULoad: %g\n", (tu + ts + tcu + tcs) / tick / up_time * 100.); + /* Allow for OS/2 not having CPU stats */ + if (ts || tu || tcu || tcs) + ap_rprintf(r, "CPULoad: %g\n", + (tu + ts + tcu + tcs) / tick / up_time * 100.); #endif - - ap_rprintf(r, "Uptime: %ld\n", (long) (up_time)); - if (up_time > 0) - ap_rprintf(r, "ReqPerSec: %g\n", (float) count / (float) up_time); - if (up_time > 0) - ap_rprintf(r, "BytesPerSec: %g\n", KBYTE * (float) kbcount / (float) up_time); + ap_rprintf(r, "Uptime: %ld\n", (long) (up_time)); + if (up_time > 0) + ap_rprintf(r, "ReqPerSec: %g\n", + (float) count / (float) up_time); - if (count > 0) - ap_rprintf(r, "BytesPerReq: %g\n", KBYTE * (float) kbcount / (float) count); - } - else { /* !short_report */ - ap_rprintf(r, "Total accesses: %lu - Total Traffic: ", count); - format_kbyte_out(r, kbcount); + if (up_time > 0) + ap_rprintf(r, "BytesPerSec: %g\n", + KBYTE * (float) kbcount / (float) up_time); + + if (count > 0) + ap_rprintf(r, "BytesPerReq: %g\n", + KBYTE * (float) kbcount / (float) count); + } + else { /* !short_report */ + ap_rprintf(r, "Total accesses: %lu - Total Traffic: ", count); + format_kbyte_out(r, kbcount); #ifndef NO_TIMES - /* Allow for OS/2 not having CPU stats */ - ap_rputs("<br>\n", r); - ap_rprintf(r, "CPU Usage: u%g s%g cu%g cs%g", - tu / tick, ts / tick, tcu / tick, tcs / tick); + /* Allow for OS/2 not having CPU stats */ + ap_rputs("<br>\n", r); + ap_rprintf(r, "CPU Usage: u%g s%g cu%g cs%g", + tu / tick, ts / tick, tcu / tick, tcs / tick); - if (ts || tu || tcu || tcs) - ap_rprintf(r, " - %.3g%% CPU load", (tu + ts + tcu + tcs) / tick / up_time * 100.); + if (ts || tu || tcu || tcs) + ap_rprintf(r, " - %.3g%% CPU load", + (tu + ts + tcu + tcs) / tick / up_time * 100.); #endif - ap_rputs("<br>\n", r); + ap_rputs("<br>\n", r); - if (up_time > 0) - ap_rprintf(r, "%.3g requests/sec - ", - (float) count / (float) up_time); + if (up_time > 0) + ap_rprintf(r, "%.3g requests/sec - ", + (float) count / (float) up_time); - if (up_time > 0) { - format_byte_out(r, KBYTE * (float) kbcount / (float) up_time); - ap_rputs("/second - ", r); - } + if (up_time > 0) { + format_byte_out(r, KBYTE * (float) kbcount / (float) up_time); + ap_rputs("/second - ", r); + } - if (count > 0) { - format_byte_out(r, KBYTE * (float) kbcount / (float) count); - ap_rputs("/request", r); - } + if (count > 0) { + format_byte_out(r, KBYTE * (float) kbcount / (float) count); + ap_rputs("/request", r); + } - ap_rputs("<br>\n", r); - } /* short_report */ -#endif /* STATUS */ + ap_rputs("<br>\n", r); + } /* short_report */ + } /* ap_extended_status */ if (!short_report) ap_rprintf(r, "\n%d requests currently being processed, %d idle servers\n" @@ -431,111 +422,113 @@ ap_rputs("\"<B><code>G</code></B>\" Gracefully finishing, \n", r); ap_rputs("\"<B><code>.</code></B>\" Open slot with no current process<P>\n", r); ap_rputs("<P>\n", r); - ap_rputs("PID Key: <br>\n", r); - ap_rputs("<UL>\n", r); - for (i = 0; i < HARD_SERVER_LIMIT; ++i) { - if (stat_buffer[i] != '.') - ap_rprintf(r, "<LI>%d in state: %c <BR>\n", pid_buffer[i], - stat_buffer[i]); + if (!ap_extended_status) { + ap_rputs("PID Key: <br>\n", r); + ap_rputs("<UL>\n", r); + for (i = 0; i < HARD_SERVER_LIMIT; ++i) { + if (stat_buffer[i] != '.') + ap_rprintf(r, "<LI>%d in state: %c <BR>\n", pid_buffer[i], + stat_buffer[i]); + } + ap_rputs("</UL>\n", r); } - ap_rputs("</UL>\n", r); } -#if defined(STATUS) - if (!short_report) { - if (no_table_report) - ap_rputs("<p><hr><h2>Server Details</h2>\n\n", r); - else + if (ap_extended_status) { + if (!short_report) { + if (no_table_report) + ap_rputs("<p><hr><h2>Server Details</h2>\n\n", r); + else #ifdef NO_TIMES - /* Allow for OS/2 not having CPU stats */ - ap_rputs("<p>\n\n<table border=0><tr><th>Srv<th>PID<th>Acc<th>M\n<th>SS<th>Req<th>Conn<th>Child<th>Slot<th>Host<th>VHost<th>Request</tr>\n\n", r); + /* Allow for OS/2 not having CPU stats */ + ap_rputs("<p>\n\n<table border=0><tr><th>Srv<th>PID<th>Acc<th>M\n<th>SS<th>Req<th>Conn<th>Child<th>Slot<th>Host<th>VHost<th>Request</tr>\n\n", r); #else - ap_rputs("<p>\n\n<table border=0><tr><th>Srv<th>PID<th>Acc<th>M<th>CPU\n<th>SS<th>Req<th>Conn<th>Child<th>Slot<th>Host<th>VHost<th>Request</tr>\n\n", r); + ap_rputs("<p>\n\n<table border=0><tr><th>Srv<th>PID<th>Acc<th>M<th>CPU\n<th>SS<th>Req<th>Conn<th>Child<th>Slot<th>Host<th>VHost<th>Request</tr>\n\n", r); #endif - } + } - for (i = 0; i < HARD_SERVER_LIMIT; ++i) { - score_record = ap_scoreboard_image->servers[i]; - ps_record = ap_scoreboard_image->parent[i]; + for (i = 0; i < HARD_SERVER_LIMIT; ++i) { + score_record = ap_scoreboard_image->servers[i]; + ps_record = ap_scoreboard_image->parent[i]; #if defined(NO_GETTIMEOFDAY) #ifndef NO_TIMES - if (score_record.start_time == (clock_t) 0) + if (score_record.start_time == (clock_t) 0) #endif /* NO_TIMES */ - req_time = 0L; + req_time = 0L; #ifndef NO_TIMES - else { - req_time = score_record.stop_time - score_record.start_time; - req_time = (req_time * 1000) / (int) tick; - } + else { + req_time = score_record.stop_time - score_record.start_time; + req_time = (req_time * 1000) / (int) tick; + } #endif /* NO_TIMES */ #else - if (score_record.start_time.tv_sec == 0L && - score_record.start_time.tv_usec == 0L) - req_time = 0L; - else - req_time = - ((score_record.stop_time.tv_sec - score_record.start_time.tv_sec) * 1000) + - ((score_record.stop_time.tv_usec - score_record.start_time.tv_usec) / 1000); -#endif - if (req_time < 0L) - req_time = 0L; - - lres = score_record.access_count; - my_lres = score_record.my_access_count; - conn_lres = score_record.conn_count; - bytes = score_record.bytes_served; - my_bytes = score_record.my_bytes_served; - conn_bytes = score_record.conn_bytes; - if (lres != 0 || (score_record.status != SERVER_READY - && score_record.status != SERVER_DEAD)) { - if (!short_report) { - if (no_table_report) { - if (score_record.status == SERVER_DEAD) - ap_rprintf(r, "<b>Server %d</b> (-): %d|%lu|%lu [", - i, (int) conn_lres, my_lres, lres); - else - ap_rprintf(r, "<b>Server %d</b> (%d): %d|%lu|%lu [", - i, (int) ps_record.pid, (int) conn_lres, my_lres, lres); - - switch (score_record.status) { - case SERVER_READY: - ap_rputs("Ready", r); - break; - case SERVER_STARTING: - ap_rputs("Starting", r); - break; - case SERVER_BUSY_READ: - ap_rputs("<b>Read</b>", r); - break; - case SERVER_BUSY_WRITE: - ap_rputs("<b>Write</b>", r); - break; - case SERVER_BUSY_KEEPALIVE: - ap_rputs("<b>Keepalive</b>", r); - break; - case SERVER_BUSY_LOG: - ap_rputs("<b>Logging</b>", r); - break; - case SERVER_BUSY_DNS: - ap_rputs("<b>DNS lookup</b>", r); - break; - case SERVER_DEAD: - ap_rputs("Dead", r); - break; - case SERVER_GRACEFUL: - ap_rputs("Graceful", r); - break; - default: - ap_rputs("?STATE?", r); - break; - } + if (score_record.start_time.tv_sec == 0L && + score_record.start_time.tv_usec == 0L) + req_time = 0L; + else + req_time = + ((score_record.stop_time.tv_sec - score_record.start_time.tv_sec) * 1000) + + ((score_record.stop_time.tv_usec - score_record.start_time.tv_usec) / 1000); +#endif + if (req_time < 0L) + req_time = 0L; + + lres = score_record.access_count; + my_lres = score_record.my_access_count; + conn_lres = score_record.conn_count; + bytes = score_record.bytes_served; + my_bytes = score_record.my_bytes_served; + conn_bytes = score_record.conn_bytes; + if (lres != 0 || (score_record.status != SERVER_READY + && score_record.status != SERVER_DEAD)) { + if (!short_report) { + if (no_table_report) { + if (score_record.status == SERVER_DEAD) + ap_rprintf(r, "<b>Server %d</b> (-): %d|%lu|%lu [", + i, (int) conn_lres, my_lres, lres); + else + ap_rprintf(r, "<b>Server %d</b> (%d): %d|%lu|%lu [", + i, (int) ps_record.pid, (int) conn_lres, my_lres, lres); + + switch (score_record.status) { + case SERVER_READY: + ap_rputs("Ready", r); + break; + case SERVER_STARTING: + ap_rputs("Starting", r); + break; + case SERVER_BUSY_READ: + ap_rputs("<b>Read</b>", r); + break; + case SERVER_BUSY_WRITE: + ap_rputs("<b>Write</b>", r); + break; + case SERVER_BUSY_KEEPALIVE: + ap_rputs("<b>Keepalive</b>", r); + break; + case SERVER_BUSY_LOG: + ap_rputs("<b>Logging</b>", r); + break; + case SERVER_BUSY_DNS: + ap_rputs("<b>DNS lookup</b>", r); + break; + case SERVER_DEAD: + ap_rputs("Dead", r); + break; + case SERVER_GRACEFUL: + ap_rputs("Graceful", r); + break; + default: + ap_rputs("?STATE?", r); + break; + } #ifdef NO_TIMES - /* Allow for OS/2 not having CPU stats */ - ap_rprintf(r, "]\n %.0f %ld (", + /* Allow for OS/2 not having CPU stats */ + ap_rprintf(r, "]\n %.0f %ld (", #else - ap_rprintf(r, "] u%g s%g cu%g cs%g\n %.0f %ld (", + ap_rprintf(r, "] u%g s%g cu%g cs%g\n %.0f %ld (", score_record.times.tms_utime / tick, score_record.times.tms_stime / tick, score_record.times.tms_cutime / tick, @@ -547,61 +540,61 @@ difftime(nowtime, score_record.last_used), #endif (long) req_time); - format_byte_out(r, conn_bytes); - ap_rputs("|", r); - format_byte_out(r, my_bytes); - ap_rputs("|", r); - format_byte_out(r, bytes); - ap_rputs(")\n", r); - ap_rprintf(r, " <i>%s {%s}</i><br>\n\n", - score_record.client, - ap_escape_html(r->pool, score_record.request)); - } - else { /* !no_table_report */ - if (score_record.status == SERVER_DEAD) - ap_rprintf(r, "<tr><td><b>%d</b><td>-<td>%d/%lu/%lu", - i, (int) conn_lres, my_lres, lres); - else - ap_rprintf(r, "<tr><td><b>%d</b><td>%d<td>%d/%lu/%lu", - i, (int) ps_record.pid, (int) conn_lres, my_lres, lres); - - switch (score_record.status) { - case SERVER_READY: - ap_rputs("<td>_", r); - break; - case SERVER_STARTING: - ap_rputs("<td><b>S</b>", r); - break; - case SERVER_BUSY_READ: - ap_rputs("<td><b>R</b>", r); - break; - case SERVER_BUSY_WRITE: - ap_rputs("<td><b>W</b>", r); - break; - case SERVER_BUSY_KEEPALIVE: - ap_rputs("<td><b>K</b>", r); - break; - case SERVER_BUSY_LOG: - ap_rputs("<td><b>L</b>", r); - break; - case SERVER_BUSY_DNS: - ap_rputs("<td><b>D</b>", r); - break; - case SERVER_DEAD: - ap_rputs("<td>.", r); - break; - case SERVER_GRACEFUL: - ap_rputs("<td>G", r); - break; - default: - ap_rputs("<td>?", r); - break; + format_byte_out(r, conn_bytes); + ap_rputs("|", r); + format_byte_out(r, my_bytes); + ap_rputs("|", r); + format_byte_out(r, bytes); + ap_rputs(")\n", r); + ap_rprintf(r, " <i>%s {%s}</i><br>\n\n", + score_record.client, + ap_escape_html(r->pool, score_record.request)); } + else { /* !no_table_report */ + if (score_record.status == SERVER_DEAD) + ap_rprintf(r, "<tr><td><b>%d</b><td>-<td>%d/%lu/%lu", + i, (int) conn_lres, my_lres, lres); + else + ap_rprintf(r, "<tr><td><b>%d</b><td>%d<td>%d/%lu/%lu", + i, (int) ps_record.pid, (int) conn_lres, my_lres, lres); + + switch (score_record.status) { + case SERVER_READY: + ap_rputs("<td>_", r); + break; + case SERVER_STARTING: + ap_rputs("<td><b>S</b>", r); + break; + case SERVER_BUSY_READ: + ap_rputs("<td><b>R</b>", r); + break; + case SERVER_BUSY_WRITE: + ap_rputs("<td><b>W</b>", r); + break; + case SERVER_BUSY_KEEPALIVE: + ap_rputs("<td><b>K</b>", r); + break; + case SERVER_BUSY_LOG: + ap_rputs("<td><b>L</b>", r); + break; + case SERVER_BUSY_DNS: + ap_rputs("<td><b>D</b>", r); + break; + case SERVER_DEAD: + ap_rputs("<td>.", r); + break; + case SERVER_GRACEFUL: + ap_rputs("<td>G", r); + break; + default: + ap_rputs("<td>?", r); + break; + } #ifdef NO_TIMES - /* Allow for OS/2 not having CPU stats */ - ap_rprintf(r, "\n<td>%.0f<td>%ld", + /* Allow for OS/2 not having CPU stats */ + ap_rprintf(r, "\n<td>%.0f<td>%ld", #else - ap_rprintf(r, "\n<td>%.2f<td>%.0f<td>%ld", + ap_rprintf(r, "\n<td>%.2f<td>%.0f<td>%ld", (score_record.times.tms_utime + score_record.times.tms_stime + score_record.times.tms_cutime + @@ -613,20 +606,20 @@ difftime(nowtime, score_record.last_used), #endif (long) req_time); - ap_rprintf(r, "<td>%-1.1f<td>%-2.2f<td>%-2.2f\n", - (float) conn_bytes / KBYTE, (float) my_bytes / MBYTE, + ap_rprintf(r, "<td>%-1.1f<td>%-2.2f<td>%-2.2f\n", + (float) conn_bytes / KBYTE, (float) my_bytes / MBYTE, (float) bytes / MBYTE); - ap_rprintf(r, "<td>%s<td nowrap>%s<td nowrap>%s</tr>\n\n", + ap_rprintf(r, "<td>%s<td nowrap>%s<td nowrap>%s</tr>\n\n", score_record.client, score_record.vhost, ap_escape_html(r->pool, score_record.request)); - } /* no_table_report */ - } /* !short_report */ - } /* if (<active child>) */ - } /* for () */ + } /* no_table_report */ + } /* !short_report */ + } /* if (<active child>) */ + } /* for () */ - if (!(short_report || no_table_report)) { + if (!(short_report || no_table_report)) { #ifdef OS2 - ap_rputs("</table>\n \ + ap_rputs("</table>\n \ <hr> \ <table>\n \ <tr><th>Srv<td>Server number\n \ @@ -640,7 +633,7 @@ <tr><th>Slot<td>Total megabytes transferred this slot\n \ </table>\n", r); #else - ap_rputs("</table>\n \ + ap_rputs("</table>\n \ <hr> \ <table>\n \ <tr><th>Srv<td>Server number\n \ @@ -655,16 +648,15 @@ <tr><th>Slot<td>Total megabytes transferred this slot\n \ </table>\n", r); #endif - } + } -#else /* !defined(STATUS) */ + } else { ap_rputs("<hr>To obtain a full report with current status information and", r); ap_rputs(" DNS and LOGGING status codes \n", r); - ap_rputs("you need to recompile Apache after adding the line <pre>", r); - ap_rputs("Rule STATUS=yes</pre>into the file <code>Configuration</code>\n", r); + ap_rputs("you need to use the <code>ExtendedStatus On</code>directive. \n", r); -#endif /* STATUS */ + } if (!short_report) { ap_rputs(ap_psignature("<HR>\n",r), r);