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 2005/03/05 21:06:58 UTC

svn commit: r156274 - in httpd/httpd/trunk: CHANGES include/ap_mmn.h include/scoreboard.h modules/generators/mod_status.c server/mpm/worker/worker.c

Author: trawick
Date: Sat Mar  5 12:06:55 2005
New Revision: 156274

URL: http://svn.apache.org/viewcvs?view=rev&rev=156274
Log:
worker MPM/mod_status: Support per-worker tracking of pid and
generation in the scoreboard so that mod_status can accurately
represent workers in processes which are gracefully terminating.

New child processes with worker MPM can take over slots of
individual threads within gracefully terminating processes.
Sometimes this is a problem (too many of these gracefully
terminating processes), so it is helpful to have mod_status
provide the information required to recognize these processes.

Modified:
    httpd/httpd/trunk/CHANGES
    httpd/httpd/trunk/include/ap_mmn.h
    httpd/httpd/trunk/include/scoreboard.h
    httpd/httpd/trunk/modules/generators/mod_status.c
    httpd/httpd/trunk/server/mpm/worker/worker.c

Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewcvs/httpd/httpd/trunk/CHANGES?view=diff&r1=156273&r2=156274
==============================================================================
--- httpd/httpd/trunk/CHANGES (original)
+++ httpd/httpd/trunk/CHANGES Sat Mar  5 12:06:55 2005
@@ -2,6 +2,12 @@
 
   [Remove entries to the current 2.0 section below, when backported]
 
+  *) worker MPM/mod_status: Support per-worker tracking of pid and
+     generation in the scoreboard so that mod_status can accurately
+     represent workers in processes which are gracefully terminating.
+     (major MMN bump)
+     [Jeff Trawick]
+
   *) Correctly export all mod_dav public functions.
      [Branko Èibej <brane xbc.nu>]
 

Modified: httpd/httpd/trunk/include/ap_mmn.h
URL: http://svn.apache.org/viewcvs/httpd/httpd/trunk/include/ap_mmn.h?view=diff&r1=156273&r2=156274
==============================================================================
--- httpd/httpd/trunk/include/ap_mmn.h (original)
+++ httpd/httpd/trunk/include/ap_mmn.h Sat Mar  5 12:06:55 2005
@@ -92,6 +92,7 @@
  * 20050217.0 (2.1.3-dev) Axed find_child_by_pid, mpm_*_completion_context (winnt mpm)
  *                        symbols from the public sector, and decorated real_exit_code
  *                        with ap_ in the win32 os.h.
+ * 20050305.0 (2.1.4-dev) added pid and generation fields to worker_score
  */
 
 #define MODULE_MAGIC_COOKIE 0x41503230UL /* "AP20" */

Modified: httpd/httpd/trunk/include/scoreboard.h
URL: http://svn.apache.org/viewcvs/httpd/httpd/trunk/include/scoreboard.h?view=diff&r1=156273&r2=156274
==============================================================================
--- httpd/httpd/trunk/include/scoreboard.h (original)
+++ httpd/httpd/trunk/include/scoreboard.h Sat Mar  5 12:06:55 2005
@@ -99,6 +99,13 @@
 #if APR_HAS_THREADS
     apr_os_thread_t tid;
 #endif
+    /* With some MPMs (e.g., worker), a worker_score can represent
+     * a thread in a terminating process which is no longer
+     * represented by the corresponding process_score.  These MPMs
+     * should set pid and generation fields in the worker_score.
+     */
+    pid_t pid;
+    ap_generation_t generation;
     unsigned char status;
     unsigned long access_count;
     apr_off_t     bytes_served;

Modified: httpd/httpd/trunk/modules/generators/mod_status.c
URL: http://svn.apache.org/viewcvs/httpd/httpd/trunk/modules/generators/mod_status.c?view=diff&r1=156273&r2=156274
==============================================================================
--- httpd/httpd/trunk/modules/generators/mod_status.c (original)
+++ httpd/httpd/trunk/modules/generators/mod_status.c Sat Mar  5 12:06:55 2005
@@ -229,8 +229,9 @@
     worker_score *ws_record;
     process_score *ps_record;
     char *stat_buffer;
-    pid_t *pid_buffer;
+    pid_t *pid_buffer, worker_pid;
     clock_t tu, ts, tcu, tcs;
+    ap_generation_t worker_generation;
 
     if (strcmp(r->handler, STATUS_MAGIC_TYPE) && 
         strcmp(r->handler, "server-status")) {
@@ -584,19 +585,27 @@
                 bytes = ws_record->bytes_served;
                 my_bytes = ws_record->my_bytes_served;
                 conn_bytes = ws_record->conn_bytes;
-
+                if (ws_record->pid) { /* MPM sets per-worker pid and generation */
+                    worker_pid = ws_record->pid;
+                    worker_generation = ws_record->generation;
+                }
+                else {
+                    worker_pid = ps_record->pid;
+                    worker_generation = ps_record->generation;
+                }
+ 
                 if (no_table_report) {
                     if (ws_record->status == SERVER_DEAD)
                         ap_rprintf(r,
                                    "<b>Server %d-%d</b> (-): %d|%lu|%lu [",
-                                   i, (int)ps_record->generation,
+                                   i, (int)worker_generation,
                                    (int)conn_lres, my_lres, lres);
                     else
                         ap_rprintf(r,
                                    "<b>Server %d-%d</b> (%"
                                    APR_PID_T_FMT "): %d|%lu|%lu [",
-                                   i, (int) ps_record->generation,
-                                   ps_record->pid,
+                                   i, (int) worker_generation,
+                                   worker_pid,
                                    (int)conn_lres, my_lres, lres);
                     
                     switch (ws_record->status) {
@@ -672,15 +681,16 @@
                     if (ws_record->status == SERVER_DEAD)
                         ap_rprintf(r,
                                    "<tr><td><b>%d-%d</b></td><td>-</td><td>%d/%lu/%lu",
-                                   i, (int)ps_record->generation,
+                                   i, (int)worker_generation,
                                    (int)conn_lres, my_lres, lres);
                     else
                         ap_rprintf(r,
                                    "<tr><td><b>%d-%d</b></td><td>%"
                                    APR_PID_T_FMT
                                    "</td><td>%d/%lu/%lu",
-                                   i, (int)ps_record->generation,
-                                   ps_record->pid, (int)conn_lres,
+                                   i, (int)worker_generation,
+                                   worker_pid,
+                                   (int)conn_lres,
                                    my_lres, lres);
                     
                     switch (ws_record->status) {

Modified: httpd/httpd/trunk/server/mpm/worker/worker.c
URL: http://svn.apache.org/viewcvs/httpd/httpd/trunk/server/mpm/worker/worker.c?view=diff&r1=156273&r2=156274
==============================================================================
--- httpd/httpd/trunk/server/mpm/worker/worker.c (original)
+++ httpd/httpd/trunk/server/mpm/worker/worker.c Sat Mar  5 12:06:55 2005
@@ -800,6 +800,8 @@
 
     free(ti);
 
+    ap_scoreboard_image->servers[process_slot][thread_slot].pid = ap_my_pid;
+    ap_scoreboard_image->servers[process_slot][thread_slot].generation = ap_my_generation;
     ap_update_child_status_from_indexes(process_slot, thread_slot, SERVER_STARTING, NULL);
 
     while (!workers_may_exit) {



Re: svn commit: r156274 - in httpd/httpd/trunk: CHANGES include/ap_mmn.h include/scoreboard.h modules/generators/mod_status.c server/mpm/worker/worker.c

Posted by Jeff Trawick <tr...@gmail.com>.
On Sat, 5 Mar 2005 22:16:47 +0100, André Malo <nd...@perlig.de> wrote:
> * Sander Temme wrote:
> 
> > This doesn't seem to have an actual MMN bump, just the mention of one.
> 
> It breaks binary compat, doesn't it? So I think, the bump is correct.

the problem was that in my original commit, I described the change in
a comment but didn't actually modify the MMN ;)

Re: svn commit: r156274 - in httpd/httpd/trunk: CHANGES include/ap_mmn.h include/scoreboard.h modules/generators/mod_status.c server/mpm/worker/worker.c

Posted by André Malo <nd...@perlig.de>.
* Sander Temme wrote:

> This doesn't seem to have an actual MMN bump, just the mention of one.

It breaks binary compat, doesn't it? So I think, the bump is correct.

nd
-- 
Winnetous Erbe: <http://pub.perlig.de/books.html#apache2>

Re: svn commit: r156274 - in httpd/httpd/trunk: CHANGES include/ap_mmn.h include/scoreboard.h modules/generators/mod_status.c server/mpm/worker/worker.c

Posted by Sander Temme <sa...@temme.net>.
On Mar 5, 2005, at 12:06 PM, trawick@apache.org wrote:

> Modified: httpd/httpd/trunk/include/ap_mmn.h
> URL:  
> http://svn.apache.org/viewcvs/httpd/httpd/trunk/include/ap_mmn.h? 
> view=diff&r1=156273&r2=156274
> ======================================================================= 
> =======
> --- httpd/httpd/trunk/include/ap_mmn.h (original)
> +++ httpd/httpd/trunk/include/ap_mmn.h Sat Mar  5 12:06:55 2005
> @@ -92,6 +92,7 @@
>   * 20050217.0 (2.1.3-dev) Axed find_child_by_pid,  
> mpm_*_completion_context (winnt mpm)
>   *                        symbols from the public sector, and  
> decorated real_exit_code
>   *                        with ap_ in the win32 os.h.
> + * 20050305.0 (2.1.4-dev) added pid and generation fields to  
> worker_score
>   */
>
>  #define MODULE_MAGIC_COOKIE 0x41503230UL /* "AP20" */

This doesn't seem to have an actual MMN bump, just the mention of one.

S.

-- 
sander@temme.net              http://www.temme.net/sander/
PGP FP: 51B4 8727 466A 0BC3 69F4  B7B8 B2BE BC40 1529 24AF