]> granicus.if.org Git - apache/commitdiff
worker MPM/mod_status: Support per-worker tracking of pid and
authorJeff Trawick <trawick@apache.org>
Sat, 5 Mar 2005 20:06:55 +0000 (20:06 +0000)
committerJeff Trawick <trawick@apache.org>
Sat, 5 Mar 2005 20:06:55 +0000 (20:06 +0000)
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.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@156274 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
include/ap_mmn.h
include/scoreboard.h
modules/generators/mod_status.c
server/mpm/worker/worker.c

diff --git a/CHANGES b/CHANGES
index f5b9e32594f98435a8879605939606c5ac03f4a2..02f3fefd90bb3fa9196dcdd590189301dfe360c6 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,12 @@ Changes with Apache 2.1.4
 
   [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>]
 
index 8af907aa799eaa960070084f72de8fc8cd846964..0c0835c1a0c83722a13fe4a9d1f68cda3b77bef9 100644 (file)
@@ -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" */
index 141775581d52f52ba6656ba1e5c86e0213d760e0..726ee1ee19bc5cc3cef035349c37d15342e84b31 100644 (file)
@@ -99,6 +99,13 @@ struct worker_score {
 #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;
index 52171323f689665507084bcd23d76da10bed72a9..6f28d024a326d27909fb5934c5e1606812cc72a4 100644 (file)
@@ -229,8 +229,9 @@ static int status_handler(request_rec *r)
     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 @@ static int status_handler(request_rec *r)
                 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 @@ static int status_handler(request_rec *r)
                     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) {
index 1f5deb7f557f39d21de773f6d69eec282751a2c4..6058624e17c154698a3127de851bbd0af30ed13b 100644 (file)
@@ -800,6 +800,8 @@ static void * APR_THREAD_FUNC worker_thread(apr_thread_t *thd, void * dummy)
 
     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) {