From: Jeff Trawick Date: Fri, 15 Mar 2002 12:04:58 +0000 (+0000) Subject: make mod_status a little faster by checking for an active server sooner in X-Git-Tag: CHANGES~35 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f3084243f2e5c90b4b3e8eaeaf9000401c753593;p=apache make mod_status a little faster by checking for an active server sooner in the main loop clean up the main loop by continuing when the server isn't active instead of introducing yet another level of nesting git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@93950 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/generators/mod_status.c b/modules/generators/mod_status.c index ac5a548859..3aecb4e2fc 100644 --- a/modules/generators/mod_status.c +++ b/modules/generators/mod_status.c @@ -556,6 +556,13 @@ static int status_handler(request_rec *r) for (i = 0; i < server_limit; ++i) { for (j = 0; j < thread_limit; ++j) { ws_record = ap_scoreboard_image->servers[i][j]; + + if (ws_record.access_count == 0 && + (ws_record.status == SERVER_READY || + ws_record.status == SERVER_DEAD)) { + continue; + } + ps_record = ap_scoreboard_image->parent[i]; if (ws_record.start_time == 0L) @@ -573,179 +580,176 @@ static int status_handler(request_rec *r) my_bytes = ws_record.my_bytes_served; conn_bytes = ws_record.conn_bytes; - if (lres != 0 || (ws_record.status != SERVER_READY - && ws_record.status != SERVER_DEAD)) { - if (!short_report) { - if (no_table_report) { - if (ws_record.status == SERVER_DEAD) - ap_rprintf(r, + if (!short_report) { + if (no_table_report) { + if (ws_record.status == SERVER_DEAD) + ap_rprintf(r, "Server %d-%d (-): %d|%lu|%lu [", i, (int)ps_record.generation, (int)conn_lres, my_lres, lres); - else - ap_rprintf(r, - "Server %d-%d (%" - APR_OS_PROC_T_FMT "): %d|%lu|%lu [", - i, (int) ps_record.generation, - ps_record.pid, - (int)conn_lres, my_lres, lres); - - switch (ws_record.status) { - case SERVER_READY: - ap_rputs("Ready", r); - break; - case SERVER_STARTING: - ap_rputs("Starting", r); - break; - case SERVER_BUSY_READ: - ap_rputs("Read", r); - break; - case SERVER_BUSY_WRITE: - ap_rputs("Write", r); - break; - case SERVER_BUSY_KEEPALIVE: - ap_rputs("Keepalive", r); - break; - case SERVER_BUSY_LOG: - ap_rputs("Logging", r); - break; - case SERVER_BUSY_DNS: - ap_rputs("DNS lookup", r); - break; - case SERVER_CLOSING: - ap_rputs("Closing", r); - break; - case SERVER_DEAD: - ap_rputs("Dead", r); - break; - case SERVER_GRACEFUL: - ap_rputs("Graceful", r); - break; - case SERVER_IDLE_KILL: - ap_rputs("Dying", r); - break; - default: - ap_rputs("?STATE?", r); - break; - } + else + ap_rprintf(r, + "Server %d-%d (%" + APR_OS_PROC_T_FMT "): %d|%lu|%lu [", + i, (int) ps_record.generation, + ps_record.pid, + (int)conn_lres, my_lres, lres); + + switch (ws_record.status) { + case SERVER_READY: + ap_rputs("Ready", r); + break; + case SERVER_STARTING: + ap_rputs("Starting", r); + break; + case SERVER_BUSY_READ: + ap_rputs("Read", r); + break; + case SERVER_BUSY_WRITE: + ap_rputs("Write", r); + break; + case SERVER_BUSY_KEEPALIVE: + ap_rputs("Keepalive", r); + break; + case SERVER_BUSY_LOG: + ap_rputs("Logging", r); + break; + case SERVER_BUSY_DNS: + ap_rputs("DNS lookup", r); + break; + case SERVER_CLOSING: + ap_rputs("Closing", r); + break; + case SERVER_DEAD: + ap_rputs("Dead", r); + break; + case SERVER_GRACEFUL: + ap_rputs("Graceful", r); + break; + case SERVER_IDLE_KILL: + ap_rputs("Dying", r); + break; + default: + ap_rputs("?STATE?", r); + break; + } #ifndef HAVE_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 %ld %ld (", - ws_record.times.tms_utime / tick, - ws_record.times.tms_stime / tick, - ws_record.times.tms_cutime / tick, - ws_record.times.tms_cstime / tick, + ap_rprintf(r, "] u%g s%g cu%g cs%g\n %ld %ld (", + ws_record.times.tms_utime / tick, + ws_record.times.tms_stime / tick, + ws_record.times.tms_cutime / tick, + ws_record.times.tms_cstime / tick, #endif - (long)((nowtime - ws_record.last_used) / - APR_USEC_PER_SEC), - (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); + (long)((nowtime - ws_record.last_used) / + APR_USEC_PER_SEC), + (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, + " %s {%s} [%s]
\n\n", + ap_escape_html(r->pool, + ws_record.client), + ap_escape_html(r->pool, + ws_record.request), + ap_escape_html(r->pool, + ws_record.vhost)); + } + else { /* !no_table_report */ + if (ws_record.status == SERVER_DEAD) ap_rprintf(r, - " %s {%s} [%s]
\n\n", - ap_escape_html(r->pool, - ws_record.client), - ap_escape_html(r->pool, - ws_record.request), - ap_escape_html(r->pool, - ws_record.vhost)); + "%d-%d-%d/%lu/%lu", + i, (int)ps_record.generation, + (int)conn_lres, my_lres, lres); + else + ap_rprintf(r, + "%d-%d%" + APR_OS_PROC_T_FMT + "%d/%lu/%lu", + i, (int)ps_record.generation, + ps_record.pid, (int)conn_lres, + my_lres, lres); + + switch (ws_record.status) { + case SERVER_READY: + ap_rputs("_", r); + break; + case SERVER_STARTING: + ap_rputs("S", r); + break; + case SERVER_BUSY_READ: + ap_rputs("R", r); + break; + case SERVER_BUSY_WRITE: + ap_rputs("W", r); + break; + case SERVER_BUSY_KEEPALIVE: + ap_rputs("K", r); + break; + case SERVER_BUSY_LOG: + ap_rputs("L", r); + break; + case SERVER_BUSY_DNS: + ap_rputs("D", r); + break; + case SERVER_CLOSING: + ap_rputs("C", r); + break; + case SERVER_DEAD: + ap_rputs(".", r); + break; + case SERVER_GRACEFUL: + ap_rputs("G", r); + break; + case SERVER_IDLE_KILL: + ap_rputs("I", r); + break; + default: + ap_rputs("?", r); + break; } - else { /* !no_table_report */ - if (ws_record.status == SERVER_DEAD) - ap_rprintf(r, - "%d-%d-%d/%lu/%lu", - i, (int)ps_record.generation, - (int)conn_lres, my_lres, lres); - else - ap_rprintf(r, - "%d-%d%" - APR_OS_PROC_T_FMT - "%d/%lu/%lu", - i, (int)ps_record.generation, - ps_record.pid, (int)conn_lres, - my_lres, lres); - - switch (ws_record.status) { - case SERVER_READY: - ap_rputs("_", r); - break; - case SERVER_STARTING: - ap_rputs("S", r); - break; - case SERVER_BUSY_READ: - ap_rputs("R", r); - break; - case SERVER_BUSY_WRITE: - ap_rputs("W", r); - break; - case SERVER_BUSY_KEEPALIVE: - ap_rputs("K", r); - break; - case SERVER_BUSY_LOG: - ap_rputs("L", r); - break; - case SERVER_BUSY_DNS: - ap_rputs("D", r); - break; - case SERVER_CLOSING: - ap_rputs("C", r); - break; - case SERVER_DEAD: - ap_rputs(".", r); - break; - case SERVER_GRACEFUL: - ap_rputs("G", r); - break; - case SERVER_IDLE_KILL: - ap_rputs("I", r); - break; - default: - ap_rputs("?", r); - break; - } - + #ifndef HAVE_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, "\n%.2f%ld%ld", - (ws_record.times.tms_utime + - ws_record.times.tms_stime + - ws_record.times.tms_cutime + - ws_record.times.tms_cstime) / tick, + ap_rprintf(r, "\n%.2f%ld%ld", + (ws_record.times.tms_utime + + ws_record.times.tms_stime + + ws_record.times.tms_cutime + + ws_record.times.tms_cstime) / tick, #endif - (long)((nowtime - ws_record.last_used) / - APR_USEC_PER_SEC), - (long)req_time); - - ap_rprintf(r, "%-1.1f%-2.2f%-2.2f\n", - (float)conn_bytes / KBYTE, (float) my_bytes / MBYTE, - (float)bytes / MBYTE); - - if (ws_record.status == SERVER_BUSY_READ) - ap_rprintf(r, - "??..reading.. \n\n"); - else - ap_rprintf(r, - "%s%s%s\n\n", - ap_escape_html(r->pool, - ws_record.client), - ap_escape_html(r->pool, - ws_record.vhost), - ap_escape_html(r->pool, - ws_record.request)); - } /* no_table_report */ - } /* !short_report */ - } /* if () */ - } /* for () */ - } + (long)((nowtime - ws_record.last_used) / + APR_USEC_PER_SEC), + (long)req_time); + + ap_rprintf(r, "%-1.1f%-2.2f%-2.2f\n", + (float)conn_bytes / KBYTE, (float) my_bytes / MBYTE, + (float)bytes / MBYTE); + + if (ws_record.status == SERVER_BUSY_READ) + ap_rprintf(r, + "??..reading.. \n\n"); + else + ap_rprintf(r, + "%s%s%s\n\n", + ap_escape_html(r->pool, + ws_record.client), + ap_escape_html(r->pool, + ws_record.vhost), + ap_escape_html(r->pool, + ws_record.request)); + } /* no_table_report */ + } /* !short_report */ + } /* for (j...) */ + } /* for (i...) */ if (!(short_report || no_table_report)) { #ifndef HAVE_TIMES