From: Jeff Trawick Date: Sun, 19 Aug 2012 16:00:57 +0000 (+0000) Subject: WinNT MPM: Store pid and generation for each thread in scoreboard X-Git-Tag: 2.5.0-alpha~6410 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aa9b7b4cc574af1a4e29b47ccd37c7bf1475eb28;p=thirdparty%2Fapache%2Fhttpd.git 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. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1374780 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index b3fb254d5b2..a059051ce08 100644 --- 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] diff --git a/server/mpm/winnt/child.c b/server/mpm/winnt/child.c index f55ab111403..b2ca691fbae 100644 --- a/server/mpm/winnt/child.c +++ b/server/mpm/winnt/child.c @@ -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); } diff --git a/server/mpm/winnt/mpm_winnt.c b/server/mpm/winnt/mpm_winnt.c index 3ce8e14453d..f677fc7239f 100644 --- a/server/mpm/winnt/mpm_winnt.c +++ b/server/mpm/winnt/mpm_winnt.c @@ -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 */ diff --git a/server/mpm/winnt/mpm_winnt.h b/server/mpm/winnt/mpm_winnt.h index 78962ddf6e6..59822ae16fd 100644 --- a/server/mpm/winnt/mpm_winnt.h +++ b/server/mpm/winnt/mpm_winnt.h @@ -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;