From: Jeff Trawick Date: Mon, 7 May 2001 16:24:14 +0000 (+0000) Subject: minor scoreboard/status improvements: X-Git-Tag: 2.0.18~66 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e4fad412b8a4ec5f501dee45b1c6b82d7a5fedc5;p=thirdparty%2Fapache%2Fhttpd.git minor scoreboard/status improvements: . get the SS field in extended status output formatted correctly (seconds since beginning of request shouldn't be a huge negative number :) ) . use APR_OS_PID_T_FMT and pid_t where appropriate in mod_status to avoid casting, some of which may have been broken on some architectures git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@89048 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/include/scoreboard.h b/include/scoreboard.h index 090b1bb5c7a..594e6e55e71 100644 --- a/include/scoreboard.h +++ b/include/scoreboard.h @@ -97,21 +97,6 @@ extern "C" { #define SERVER_IDLE_KILL 11 /* Server is cleaning up idle children. */ #define SERVER_NUM_STATUS 12 /* number of status settings */ -/* A "virtual time" is simply a counter that indicates that a child is - * making progress. The parent checks up on each child, and when they have - * made progress it resets the last_rtime element. But when the child hasn't - * made progress in a time that's roughly timeout_len seconds long, it is - * sent a SIGALRM. - * - * vtime is an optimization that is used only when the scoreboard is in - * shared memory (it's not easy/feasible to do it in a scoreboard file). - * The essential observation is that timeouts rarely occur, the vast majority - * of hits finish before any timeout happens. So it really sucks to have to - * ask the operating system to set up and destroy alarms many times during - * a request. - */ -typedef unsigned vtime_t; - /* Type used for generation indicies. Startup and every restart cause a * new generation of children to be spawned. Children within the same * generation share the same configuration information -- pointers to stuff @@ -166,7 +151,7 @@ typedef struct { #ifdef HAVE_TIMES struct tms times; #endif - time_t last_used; + apr_time_t last_used; char client[32]; /* Keep 'em small... */ char request[64]; /* We just want an idea... */ server_rec *vhostrec; /* What virtual host is being accessed? */ diff --git a/modules/generators/mod_status.c b/modules/generators/mod_status.c index e7668b827b1..493b974e7be 100644 --- a/modules/generators/mod_status.c +++ b/modules/generators/mod_status.c @@ -254,7 +254,7 @@ static int status_handler(request_rec *r) short_score score_record; parent_score ps_record; char stat_buffer[HARD_SERVER_LIMIT * HARD_THREAD_LIMIT]; - int pid_buffer[HARD_SERVER_LIMIT * HARD_THREAD_LIMIT]; + pid_t pid_buffer[HARD_SERVER_LIMIT * HARD_THREAD_LIMIT]; clock_t tu, ts, tcu, tcs; server_rec *vhost; @@ -321,7 +321,7 @@ static int status_handler(request_rec *r) ps_record = ap_scoreboard_image->parent[i]; res = score_record.status; stat_buffer[indx] = status_flags[res]; - pid_buffer[indx] = (int) ps_record.pid; + pid_buffer[indx] = ps_record.pid; if (res == SERVER_READY) ready++; else if (res != SERVER_DEAD) @@ -348,7 +348,7 @@ static int status_handler(request_rec *r) } /* up_time in seconds */ - up_time = (apr_uint32_t) ((nowtime - ap_restart_time)/1000000); + up_time = (apr_uint32_t) ((nowtime - ap_restart_time)/APR_USEC_PER_SEC); if (!short_report) { ap_rputs(DOCTYPE_HTML_3_2 @@ -479,8 +479,9 @@ static int status_handler(request_rec *r) int indx = (i * HARD_THREAD_LIMIT) + j; if (stat_buffer[indx] != '.') { - ap_rprintf(r, " %d in state: %c ", pid_buffer[i], - stat_buffer[indx]); + ap_rprintf(r, " %" APR_OS_PROC_T_FMT + " in state: %c ", pid_buffer[i], + stat_buffer[indx]); if (++k >= 3) { ap_rputs("\n", r); k = 0; @@ -556,9 +557,10 @@ static int status_handler(request_rec *r) my_lres, lres); else ap_rprintf(r, - "Server %d-%d (%d): %d|%lu|%lu [", + "Server %d-%d (%" APR_OS_PROC_T_FMT + "): %d|%lu|%lu [", i, (int) ps_record.generation, - (int) ps_record.pid, + ps_record.pid, (int) conn_lres, my_lres, lres); switch (score_record.status) { @@ -598,13 +600,13 @@ static int status_handler(request_rec *r) 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 %ld %ld (", score_record.times.tms_utime / tick, score_record.times.tms_stime / tick, score_record.times.tms_cutime / tick, score_record.times.tms_cstime / tick, #endif - difftime(nowtime, score_record.last_used), + (long)((nowtime - score_record.last_used) / APR_USEC_PER_SEC), (long) req_time); format_byte_out(r, conn_bytes); ap_rputs("|", r); @@ -626,9 +628,10 @@ static int status_handler(request_rec *r) (int) conn_lres, my_lres, lres); else ap_rprintf(r, - "%d-%d%d%d/%lu/%lu", + "%d-%d%" APR_OS_PROC_T_FMT + "%d/%lu/%lu", i, (int) ps_record.generation, - (int) ps_record.pid, (int) conn_lres, + ps_record.pid, (int) conn_lres, my_lres, lres); switch (score_record.status) { @@ -667,13 +670,13 @@ static int status_handler(request_rec *r) /* Allow for OS/2 not having CPU stats */ ap_rprintf(r, "\n%.0f%ld", #else - ap_rprintf(r, "\n%.2f%.0f%ld", + ap_rprintf(r, "\n%.2f%ld%ld", (score_record.times.tms_utime + score_record.times.tms_stime + score_record.times.tms_cutime + score_record.times.tms_cstime) / tick, #endif - difftime(nowtime, score_record.last_used), + (long)((nowtime - score_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, diff --git a/server/scoreboard.c b/server/scoreboard.c index d93a84aaecc..82531c997a1 100644 --- a/server/scoreboard.c +++ b/server/scoreboard.c @@ -286,6 +286,7 @@ int ap_update_child_status(int child_num, int thread_num, int status, request_re } if (ap_extended_status) { + ss->last_used = apr_time_now(); if (status == SERVER_READY || status == SERVER_DEAD) { /* * Reset individual counters