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 2011/11/10 18:46:57 UTC
svn commit: r1200449 - in /httpd/httpd/trunk: CHANGES include/mpm_common.h
server/core.c server/mpm_common.c
Author: trawick
Date: Thu Nov 10 17:46:57 2011
New Revision: 1200449
URL: http://svn.apache.org/viewvc?rev=1200449&view=rev
Log:
end-generation hook: Fix false notification of end-of-generation for
temporary intervals with no active MPM children.
Modified:
httpd/httpd/trunk/CHANGES
httpd/httpd/trunk/include/mpm_common.h
httpd/httpd/trunk/server/core.c
httpd/httpd/trunk/server/mpm_common.c
Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=1200449&r1=1200448&r2=1200449&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Thu Nov 10 17:46:57 2011
@@ -1,6 +1,9 @@
-*- coding: utf-8 -*-
Changes with Apache 2.3.16
+ *) end-generation hook: Fix false notification of end-of-generation for
+ temporary intervals with no active MPM children. [Jeff Trawick]
+
*) mod_ssl: Add support for RFC 5077 TLS Session tickets.
[Paul Querna]
Modified: httpd/httpd/trunk/include/mpm_common.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/mpm_common.h?rev=1200449&r1=1200448&r2=1200449&view=diff
==============================================================================
--- httpd/httpd/trunk/include/mpm_common.h (original)
+++ httpd/httpd/trunk/include/mpm_common.h Thu Nov 10 17:46:57 2011
@@ -137,6 +137,11 @@ void ap_register_extra_mpm_process(pid_t
int ap_unregister_extra_mpm_process(pid_t pid, ap_generation_t *old_gen);
/**
+ * Pool cleanup for end-generation hook implementation
+ */
+apr_status_t ap_mpm_end_gen_helper(void *unused);
+
+/**
* Safely signal an MPM child process, if the process is in the
* current process group. Otherwise fail.
* @param pid the process id of a child process to signal
Modified: httpd/httpd/trunk/server/core.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/core.c?rev=1200449&r1=1200448&r2=1200449&view=diff
==============================================================================
--- httpd/httpd/trunk/server/core.c (original)
+++ httpd/httpd/trunk/server/core.c Thu Nov 10 17:46:57 2011
@@ -4389,6 +4389,8 @@ static int core_post_config(apr_pool_t *
"or other system security module is loaded.");
return !OK;
}
+ apr_pool_cleanup_register(pconf, NULL, ap_mpm_end_gen_helper,
+ apr_pool_cleanup_null);
return OK;
}
Modified: httpd/httpd/trunk/server/mpm_common.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm_common.c?rev=1200449&r1=1200448&r2=1200449&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm_common.c (original)
+++ httpd/httpd/trunk/server/mpm_common.c Thu Nov 10 17:46:57 2011
@@ -131,6 +131,7 @@ typedef struct mpm_gen_info_t {
APR_RING_ENTRY(mpm_gen_info_t) link;
int gen; /* which gen? */
int active; /* number of active processes */
+ int done; /* gen finished? (whether or not active processes) */
} mpm_gen_info_t;
APR_RING_HEAD(mpm_gen_info_head_t, mpm_gen_info_t);
@@ -413,9 +414,50 @@ AP_DECLARE(apr_status_t) ap_mpm_query(in
return rv;
}
+static void end_gen(mpm_gen_info_t *gi)
+{
+ ap_log_error(APLOG_MARK, APLOG_TRACE4, 0, ap_server_conf,
+ "end of generation %d", gi->gen);
+ ap_run_end_generation(ap_server_conf, gi->gen);
+ APR_RING_REMOVE(gi, link);
+ APR_RING_INSERT_HEAD(unused_geninfo, gi, mpm_gen_info_t, link);
+}
+
+apr_status_t ap_mpm_end_gen_helper(void *unused) /* cleanup on pconf */
+{
+ int gen = ap_config_generation - 1; /* differs from MPM generation */
+ mpm_gen_info_t *cur;
+
+ if (geninfo == NULL) {
+ /* initial pconf teardown, MPM hasn't run */
+ return APR_SUCCESS;
+ }
+
+ cur = APR_RING_FIRST(geninfo);
+ while (cur != APR_RING_SENTINEL(geninfo, mpm_gen_info_t, link) &&
+ cur->gen != gen) {
+ cur = APR_RING_NEXT(cur, link);
+ }
+
+ if (cur == APR_RING_SENTINEL(geninfo, mpm_gen_info_t, link)) {
+ /* last child of generation already exited */
+ ap_log_error(APLOG_MARK, APLOG_TRACE4, 0, ap_server_conf,
+ "no record of generation %d", gen);
+ }
+ else {
+ cur->done = 1;
+ if (cur->active == 0) {
+ end_gen(cur);
+ }
+ }
+
+ return APR_SUCCESS;
+}
+
/* core's child-status hook
* tracks number of remaining children per generation and
- * runs the end-generation hook when a generation finishes
+ * runs the end-generation hook when the last child of
+ * a generation exits
*/
void ap_core_child_status(server_rec *s, pid_t pid,
ap_generation_t gen, int slot,
@@ -446,6 +488,7 @@ void ap_core_child_status(server_rec *s,
if (!APR_RING_EMPTY(unused_geninfo, mpm_gen_info_t, link)) {
cur = APR_RING_FIRST(unused_geninfo);
APR_RING_REMOVE(cur, link);
+ cur->active = cur->done = 0;
}
else {
cur = apr_pcalloc(s->process->pool, sizeof *cur);
@@ -466,12 +509,8 @@ void ap_core_child_status(server_rec *s,
}
else {
--cur->active;
- if (!cur->active) {
- ap_log_error(APLOG_MARK, APLOG_TRACE4, 0, ap_server_conf,
- "end of generation %d", gen);
- ap_run_end_generation(ap_server_conf, gen);
- APR_RING_REMOVE(cur, link);
- APR_RING_INSERT_HEAD(unused_geninfo, cur, mpm_gen_info_t, link);
+ if (!cur->active && cur->done) { /* no children, server has stopped/restarted */
+ end_gen(cur);
}
}
break;