You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by tr...@apache.org on 2003/12/14 01:26:12 UTC

cvs commit: httpd-2.0/modules/generators mod_status.c

trawick     2003/12/13 16:26:12

  Modified:    .        Tag: APACHE_2_0_BRANCH CHANGES STATUS
               modules/generators Tag: APACHE_2_0_BRANCH mod_status.c
  Log:
  merge this fix from 2.1-dev:
  
    mod_status: Report total CPU time accurately when using a threaded
    MPM.
  
  PR:             23795
  Submitted by:   Jeff Trawick
  Reviewed by:    jim, ianh, nd
  
  Revision  Changes    Path
  No                   revision
  No                   revision
  1.988.2.196 +3 -0      httpd-2.0/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/CHANGES,v
  retrieving revision 1.988.2.195
  retrieving revision 1.988.2.196
  diff -u -r1.988.2.195 -r1.988.2.196
  --- CHANGES	14 Dec 2003 00:17:40 -0000	1.988.2.195
  +++ CHANGES	14 Dec 2003 00:26:11 -0000	1.988.2.196
  @@ -1,5 +1,8 @@
   Changes with Apache 2.0.49
   
  +  *) mod_status: Report total CPU time accurately when using a threaded
  +     MPM.  PR 23795.  [Jeff Trawick]
  +
     *) Fix memory leak in handling of request bodies during reverse
        proxy operations.  PR 24991. [Larry Toppi <larry.toppi citrix.com>]
   
  
  
  
  1.751.2.597 +1 -8      httpd-2.0/STATUS
  
  Index: STATUS
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/STATUS,v
  retrieving revision 1.751.2.596
  retrieving revision 1.751.2.597
  diff -u -r1.751.2.596 -r1.751.2.597
  --- STATUS	14 Dec 2003 00:17:41 -0000	1.751.2.596
  +++ STATUS	14 Dec 2003 00:26:12 -0000	1.751.2.597
  @@ -297,13 +297,6 @@
            nd replies: But if it can't be 0 the alternatives thereafter make no
              sense anymore, right?
   
  -    * mod_status: Report total CPU time accurately when using a
  -      threaded MPM.  PR: 23795
  -        modules/generators/mod_status.c r1.75
  -      +1: trawick, jim, ianh
  -       (nd: +1 on concept, lacking knowledge prevents me from definitely +1'ing
  -            it.)
  -
       * Let mod_autoindex show filenames containing special characters.
         PR 13598.
           server/request.c: r1.130
  
  
  
  No                   revision
  No                   revision
  1.71.2.2  +52 -5     httpd-2.0/modules/generators/mod_status.c
  
  Index: mod_status.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/generators/mod_status.c,v
  retrieving revision 1.71.2.1
  retrieving revision 1.71.2.2
  diff -u -r1.71.2.1 -r1.71.2.2
  --- mod_status.c	3 Feb 2003 17:31:40 -0000	1.71.2.1
  +++ mod_status.c	14 Dec 2003 00:26:12 -0000	1.71.2.2
  @@ -141,6 +141,14 @@
   
   int server_limit, thread_limit;
   
  +#ifdef HAVE_TIMES
  +/* ugh... need to know if we're running with a pthread implementation
  + * such as linuxthreads that treats individual threads as distinct
  + * processes; that affects how we add up CPU time in a process
  + */
  +static pid_t child_pid;
  +#endif
  +
   /*
    * command-related code. This is here to prevent use of ExtendedStatus
    * without status_module included.
  @@ -249,6 +257,7 @@
       long req_time;
   #ifdef HAVE_TIMES
       float tick;
  +    int times_per_thread = getpid() != child_pid;
   #endif
       int short_report;
       int no_table_report;
  @@ -335,6 +344,11 @@
       }
   
       for (i = 0; i < server_limit; ++i) {
  +#ifdef HAVE_TIMES
  +        clock_t proc_tu = 0, proc_ts = 0, proc_tcu = 0, proc_tcs = 0;
  +        clock_t tmp_tu, tmp_ts, tmp_tcu, tmp_tcs;
  +#endif
  +        
           ps_record = ap_get_scoreboard_process(i);
           for (j = 0; j < thread_limit; ++j) {
               int indx = (i * thread_limit) + j;
  @@ -363,10 +377,28 @@
   
                   if (lres != 0 || (res != SERVER_READY && res != SERVER_DEAD)) {
   #ifdef HAVE_TIMES
  -                    tu += ws_record->times.tms_utime;
  -                    ts += ws_record->times.tms_stime;
  -                    tcu += ws_record->times.tms_cutime;
  -                    tcs += ws_record->times.tms_cstime;
  +                    tmp_tu = ws_record->times.tms_utime;
  +                    tmp_ts = ws_record->times.tms_stime;
  +                    tmp_tcu = ws_record->times.tms_cutime;
  +                    tmp_tcs = ws_record->times.tms_cstime;
  +
  +                    if (times_per_thread) {
  +                        proc_tu += tmp_tu;
  +                        proc_ts += tmp_ts;
  +                        proc_tcu += tmp_tcu;
  +                        proc_tcs += proc_tcs;
  +                    }
  +                    else {
  +                        if (tmp_tu > proc_tu ||
  +                            tmp_ts > proc_ts ||
  +                            tmp_tcu > proc_tcu ||
  +                            tmp_tcs > proc_tcs) {
  +                            proc_tu = tmp_tu;
  +                            proc_ts = tmp_ts;
  +                            proc_tcu = tmp_tcu;
  +                            proc_tcs = proc_tcs;
  +                        }
  +                    }
   #endif /* HAVE_TIMES */
   
                       count += lres;
  @@ -379,7 +411,12 @@
                   }
               }
           }
  -
  +#ifdef HAVE_TIMES
  +        tu += proc_tu;
  +        ts += proc_ts;
  +        tcu += proc_tcu;
  +        tcs += proc_tcs;
  +#endif
           pid_buffer[i] = ps_record->pid;
       }
   
  @@ -814,10 +851,20 @@
       return OK;
   }
   
  +#ifdef HAVE_TIMES
  +static void status_child_init(apr_pool_t *p, server_rec *s)
  +{
  +    child_pid = getpid();
  +}
  +#endif
  +
   static void register_hooks(apr_pool_t *p)
   {
       ap_hook_handler(status_handler, NULL, NULL, APR_HOOK_MIDDLE);
       ap_hook_post_config(status_init, NULL, NULL, APR_HOOK_MIDDLE);
  +#ifdef HAVE_TIMES
  +    ap_hook_child_init(status_child_init, NULL, NULL, APR_HOOK_MIDDLE);
  +#endif
   }
   
   module AP_MODULE_DECLARE_DATA status_module =