]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
WinNT MPM: Store pid and generation for each thread in scoreboard
authorJeff Trawick <trawick@apache.org>
Sun, 19 Aug 2012 16:00:57 +0000 (16:00 +0000)
committerJeff Trawick <trawick@apache.org>
Sun, 19 Aug 2012 16:00:57 +0000 (16:00 +0000)
to allow tracking of threads from exiting children via mod_status
or other such mechanisms.

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

CHANGES
server/mpm/winnt/child.c
server/mpm/winnt/mpm_winnt.c
server/mpm/winnt/mpm_winnt.h

diff --git a/CHANGES b/CHANGES
index b3fb254d5b241a2105f3ce1a1f834637a4ad0027..a059051ce084010ea8db1b26cfd40e4bdaa38277 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,10 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache 2.5.0
 
+  *) WinNT MPM: Store pid and generation for each thread in scoreboard
+     to allow tracking of threads from exiting children via mod_status
+     or other such mechanisms.  [Jeff Trawick]
+
   *) Windows: Fix output of -M, -L, and similar command-line options
      which display information about the server configuration.
      [Jeff Trawick]
index f55ab11140315f992accc224bcd006624d12dad6..b2ca691fbae7159954ff72edc4f512cbdd5de6b1 100644 (file)
@@ -1016,10 +1016,18 @@ void child_main(apr_pool_t *pconf)
     apr_thread_mutex_create(&child_lock, APR_THREAD_MUTEX_DEFAULT, pchild);
 
     while (1) {
+        int from_previous_generation = 0, starting_up = 0;
+
         for (i = 0; i < ap_threads_per_child; i++) {
             int *score_idx;
             int status = ap_scoreboard_image->servers[0][i].status;
             if (status != SERVER_GRACEFUL && status != SERVER_DEAD) {
+                if (ap_scoreboard_image->servers[0][i].generation != my_generation) {
+                    ++from_previous_generation;
+                }
+                else if (status == SERVER_STARTING) {
+                    ++starting_up;
+                }
                 continue;
             }
             ap_update_child_status_from_indexes(0, i, SERVER_STARTING, NULL);
@@ -1038,6 +1046,8 @@ void child_main(apr_pool_t *pconf)
                 ap_signal_parent(SIGNAL_PARENT_SHUTDOWN);
                 goto shutdown;
             }
+            ap_scoreboard_image->servers[0][i].pid = my_pid;
+            ap_scoreboard_image->servers[0][i].generation = my_generation;
             threads_created++;
             /* Save the score board index in ht keyed to the thread handle.
              * We need this when cleaning up threads down below...
@@ -1063,6 +1073,9 @@ void child_main(apr_pool_t *pconf)
         }
         /* wait for previous generation to clean up an entry in the scoreboard
          */
+        ap_log_error(APLOG_MARK, APLOG_TRACE2, 0, ap_server_conf,
+                     "Child: %d threads starting up, %d remain from a prior generation",
+                     starting_up, from_previous_generation);
         apr_sleep(1 * APR_USEC_PER_SEC);
     }
 
index 3ce8e14453d3c77fa705e9238eca09c30e86fafc..f677fc7239f63602a898a6824876bcc89a60af05 100644 (file)
@@ -64,7 +64,7 @@
 extern apr_shm_t *ap_scoreboard_shm;
 
 /* my_generation is returned to the scoreboard code */
-static volatile ap_generation_t my_generation=0;
+volatile ap_generation_t my_generation=0;
 
 /* Definitions of WINNT MPM specific config globals */
 static HANDLE shutdown_event;  /* used to signal the parent to shutdown */
index 78962ddf6e6342be94f1a63acea4c9cc4d3a8234..59822ae16fd0658d31e251977d8d1420885a384c 100644 (file)
@@ -71,6 +71,7 @@ extern module AP_MODULE_DECLARE_DATA mpm_winnt_module;
 extern int ap_threads_per_child;
 
 extern DWORD my_pid;
+extern volatile ap_generation_t my_generation;
 extern apr_proc_mutex_t *start_mutex;
 extern HANDLE exit_event;