manoj       99/02/14 23:43:58

  Modified:    pthreads/src/modules/standard mod_status.c
  Log:
  Started fixing up mod_status to deal with threads. All this does is add
  an extra nested loop for the different threads in each process. There is
  probably a better way to do this, but it works, and it has helped me
  find another bug.
  
  Revision  Changes    Path
  1.4       +36 -20    apache-apr/pthreads/src/modules/standard/mod_status.c
  
  Index: mod_status.c
  ===================================================================
  RCS file: /home/cvs/apache-apr/pthreads/src/modules/standard/mod_status.c,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -u -r1.3 -r1.4
  --- mod_status.c      1999/02/10 21:06:54     1.3
  +++ mod_status.c      1999/02/15 07:43:57     1.4
  @@ -227,11 +227,10 @@
   
   static int status_handler(request_rec *r)
   {
  -#if 0
       char *loc;
       time_t nowtime = time(NULL);
       time_t up_time;
  -    int i, res;
  +    int i, j, res;
       int ready = 0;
       int busy = 0;
       unsigned long count = 0;
  @@ -250,10 +249,11 @@
   #endif
       int short_report = 0;
       int no_table_report = 0;
  -    short_score score_record;
  +    thread_score score_record;
       parent_score ps_record;
  -    char stat_buffer[HARD_SERVER_LIMIT];
  +    char stat_buffer[HARD_SERVER_LIMIT][HARD_THREAD_LIMIT];
       int pid_buffer[HARD_SERVER_LIMIT];
  +    int tid_buffer[HARD_SERVER_LIMIT][HARD_THREAD_LIMIT];
       clock_t tu, ts, tcu, tcs;
       server_rec *vhost;
   
  @@ -306,12 +306,15 @@
       if (r->header_only)
        return 0;
   
  +    ap_sync_scoreboard_image();
       for (i = 0; i < HARD_SERVER_LIMIT; ++i) {
  -     score_record = ap_scoreboard_image->servers[i];
  +    for (j = 0; j < HARD_THREAD_LIMIT; ++j) {
  +     score_record = ap_scoreboard_image->servers[i][j];
        ps_record = ap_scoreboard_image->parent[i];
        res = score_record.status;
  -     stat_buffer[i] = status_flags[res];
  +     stat_buffer[i][j] = status_flags[res];
        pid_buffer[i] = (int) ps_record.pid;
  +     tid_buffer[i][j] = (int) score_record.tid;
        if (res == SERVER_READY)
            ready++;
        else if (res != SERVER_DEAD)
  @@ -335,9 +338,12 @@
            }
        }
       }
  +    }
   
       up_time = nowtime - ap_restart_time;
   
  +    /* ap_hard_timeout("send status info", r); */
  +
       if (!short_report) {
        ap_rputs("<HTML><HEAD>\n<TITLE>Apache Status</TITLE>\n</HEAD><BODY>\n", 
r);
        ap_rputs("<H1>Apache Server Status for ", r);
  @@ -431,10 +437,12 @@
        ap_rputs("Scoreboard: ", r);
   
       for (i = 0; i < HARD_SERVER_LIMIT; ++i) {
  -     ap_rputc(stat_buffer[i], r);
  +    for (j = 0; j < HARD_THREAD_LIMIT; ++j) {
  +     ap_rputc(stat_buffer[i][j], r);
        if ((i % STATUS_MAXLINE == (STATUS_MAXLINE - 1)) && !short_report)
            ap_rputs("\n", r);
       }
  +    }
   
       if (short_report)
        ap_rputs("\n", r);
  @@ -452,20 +460,22 @@
        ap_rputs("\"<B><code>.</code></B>\" Open slot with no current 
process<P>\n", r);
        ap_rputs("<P>\n", r);
        if (!ap_extended_status) {
  -         int j = 0;
  +         int k = 0;
            ap_rputs("PID Key: <br>\n", r);
            ap_rputs("<PRE>\n", r);
            for (i = 0; i < HARD_SERVER_LIMIT; ++i) {
  -             if (stat_buffer[i] != '.') {
  +         for (j = 0; j < HARD_SERVER_LIMIT; ++j) {
  +             if (stat_buffer[i][j] != '.') {
                    ap_rprintf(r, "   %d in state: %c ", pid_buffer[i],
  -                  stat_buffer[i]);
  -                 if (++j >= 3) {
  +                  stat_buffer[i][j]);
  +                 if (++k >= 3) {
                        ap_rputs("\n", r);
  -                     j = 0;
  +                     k = 0;
                    } else
                        ap_rputs(",", r);
                }
            }
  +         }
            ap_rputs("\n", r);
            ap_rputs("</PRE>\n", r);
        }
  @@ -478,14 +488,15 @@
            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>Client<th>VHost<th>Request</tr>\n\n",
 r);
  +             ap_rputs("<p>\n\n<table 
border=0><tr><th>Srv<th>PID<th>TID<th>Acc<th>M\n<th>SS<th>Req<th>Conn<th>Child<th>Slot<th>Client<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>Client<th>VHost<th>Request</tr>\n\n",
 r);
  +             ap_rputs("<p>\n\n<table 
border=0><tr><th>Srv<th>PID<th>TID<th>Acc<th>M<th>CPU\n<th>SS<th>Req<th>Conn<th>Child<th>Slot<th>Client<th>VHost<th>Request</tr>\n\n",
 r);
   #endif
        }
   
        for (i = 0; i < HARD_SERVER_LIMIT; ++i) {
  -         score_record = ap_scoreboard_image->servers[i];
  +     for (j = 0; j < HARD_THREAD_LIMIT; ++j) {
  +         score_record = ap_scoreboard_image->servers[i][j];
            ps_record = ap_scoreboard_image->parent[i];
            vhost = score_record.vhostrec;
            if (ps_record.generation != ap_my_generation) {
  @@ -532,9 +543,10 @@
                                my_lres, lres);
                        else
                            ap_rprintf(r,
  -                             "<b>Server %d-%d</b> (%d): %d|%lu|%lu [",
  +                             "<b>Server %d-%d</b> (pid: %d, tid: %d): 
%d|%lu|%lu [",
                                i, (int) ps_record.generation,
                                (int) ps_record.pid,
  +                             (int) score_record.tid,
                                (int) conn_lres, my_lres, lres);
   
                        switch (score_record.status) {
  @@ -600,14 +612,14 @@
                    else {              /* !no_table_report */
                        if (score_record.status == SERVER_DEAD)
                            ap_rprintf(r,
  -                             "<tr><td><b>%d-%d</b><td>-<td>%d/%lu/%lu",
  +                             "<tr><td><b>%d-%d</b><td>-<td>-<td>%d/%lu/%lu",
                                i, (int) ps_record.generation,
                                (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>%d<td>%d<td>%d/%lu/%lu",
                                i, (int) ps_record.generation,
  -                             (int) ps_record.pid, (int) conn_lres,
  +                             (int) ps_record.pid, (int) score_record.tid, 
(int) conn_lres,
                                my_lres, lres);
   
                        switch (score_record.status) {
  @@ -674,6 +686,7 @@
                }                       /* !short_report */
            }                   /* if (<active child>) */
        }                               /* for () */
  +     }
   
        if (!(short_report || no_table_report)) {
   #ifdef NO_TIMES
  @@ -682,6 +695,7 @@
   <table>\n \
   <tr><th>Srv<td>Child Server number - generation\n \
   <tr><th>PID<td>OS process ID\n \
  +<tr><th>TID<td>OS thread ID\n \
   <tr><th>Acc<td>Number of accesses this connection / this child / this slot\n 
\
   <tr><th>M<td>Mode of operation\n \
   <tr><th>SS<td>Seconds since beginning of most recent request\n \
  @@ -696,6 +710,7 @@
   <table>\n \
   <tr><th>Srv<td>Child Server number - generation\n \
   <tr><th>PID<td>OS process ID\n \
  +<tr><th>TID<td>OS thread ID\n \
   <tr><th>Acc<td>Number of accesses this connection / this child / this slot\n 
\
   <tr><th>M<td>Mode of operation\n \
   <tr><th>CPU<td>CPU usage, number of seconds\n \
  @@ -719,7 +734,8 @@
        ap_rputs(ap_psignature("<HR>\n",r), r);
        ap_rputs("</BODY></HTML>\n", r);
       }
  -#endif
  +
  +    /* ap_kill_timeout(r); */
       return 0;
   }
   
  
  
  

Reply via email to