]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
minor scoreboard/status improvements:
authorJeff Trawick <trawick@apache.org>
Mon, 7 May 2001 16:24:14 +0000 (16:24 +0000)
committerJeff Trawick <trawick@apache.org>
Mon, 7 May 2001 16:24:14 +0000 (16:24 +0000)
. 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

include/scoreboard.h
modules/generators/mod_status.c
server/scoreboard.c

index 090b1bb5c7aee1cfd2402528eab72bda80466f48..594e6e55e71d9a9712ee98bdc2496018a749c9ed 100644 (file)
@@ -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? */
index e7668b827b1a64aee7efa510f1b14ecfb055d24e..493b974e7be29cb01e6f9a179b05ae556489a1bb 100644 (file)
@@ -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,
-                               "<b>Server %d-%d</b> (%d): %d|%lu|%lu [",
+                               "<b>Server %d-%d</b> (%" 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,
-                               "<tr><td><b>%d-%d</b><td>%d<td>%d/%lu/%lu",
+                               "<tr><td><b>%d-%d</b><td>%" APR_OS_PROC_T_FMT 
+                                "<td>%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<td>%.0f<td>%ld",
 #else
-                       ap_rprintf(r, "\n<td>%.2f<td>%.0f<td>%ld",
+                       ap_rprintf(r, "\n<td>%.2f<td>%ld<td>%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, "<td>%-1.1f<td>%-2.2f<td>%-2.2f\n",
                           (float) conn_bytes / KBYTE, (float) my_bytes / MBYTE,
index d93a84aaecc1c04d1a33af00c2d0671b7bc3e91b..82531c997a1a38dea8572f46d2247b680958eeaa 100644 (file)
@@ -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