You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by ic...@apache.org on 2021/08/10 08:43:12 UTC
svn commit: r1892167 - in /httpd/httpd/branches/2.4.x: CHANGES
include/ap_mmn.h include/mpm_common.h server/mpm/event/event.c
server/mpm/prefork/prefork.c server/mpm/worker/worker.c server/mpm_common.c
Author: icing
Date: Tue Aug 10 08:43:11 2021
New Revision: 1892167
URL: http://svn.apache.org/viewvc?rev=1892167&view=rev
Log:
Merged r1891919 from trunk:
*) core: add hook child_stopping hook that gets called when the MPM is stopping a
child process. The additional graceful parameter allows registered hooks
to free resources early during a graceful shutdown.
Modified:
httpd/httpd/branches/2.4.x/CHANGES
httpd/httpd/branches/2.4.x/include/ap_mmn.h
httpd/httpd/branches/2.4.x/include/mpm_common.h
httpd/httpd/branches/2.4.x/server/mpm/event/event.c
httpd/httpd/branches/2.4.x/server/mpm/prefork/prefork.c
httpd/httpd/branches/2.4.x/server/mpm/worker/worker.c
httpd/httpd/branches/2.4.x/server/mpm_common.c
Modified: httpd/httpd/branches/2.4.x/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/CHANGES?rev=1892167&r1=1892166&r2=1892167&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/CHANGES [utf-8] (original)
+++ httpd/httpd/branches/2.4.x/CHANGES [utf-8] Tue Aug 10 08:43:11 2021
@@ -1,6 +1,11 @@
-*- coding: utf-8 -*-
Changes with Apache 2.4.49
+ * core/mpm: add hook 'child_stopping` that gets called when the MPM is
+ stopping a child process. The additional `graceful` parameter allows
+ registered hooks to free resources early during a graceful shutdown.
+ [Yann Ylavic, Stefan Eissing]
+
*) mod_proxy: Fix icomplete initialization of BalancerMember(s) from the
balancer-manager, which can lead to a crash. [Yann Ylavic]
Modified: httpd/httpd/branches/2.4.x/include/ap_mmn.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/include/ap_mmn.h?rev=1892167&r1=1892166&r2=1892167&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/include/ap_mmn.h (original)
+++ httpd/httpd/branches/2.4.x/include/ap_mmn.h Tue Aug 10 08:43:11 2021
@@ -567,6 +567,8 @@
* pre_translate_name hook and
* Add map_encoded_one and map_encoded_all bits to
* proxy_server_conf.
+ * 20120211.110 (2.4.49-dev) Add hook child_stopping to get informed that a child
+ * is being shut down.
*/
#define MODULE_MAGIC_COOKIE 0x41503234UL /* "AP24" */
@@ -574,7 +576,7 @@
#ifndef MODULE_MAGIC_NUMBER_MAJOR
#define MODULE_MAGIC_NUMBER_MAJOR 20120211
#endif
-#define MODULE_MAGIC_NUMBER_MINOR 109 /* 0...n */
+#define MODULE_MAGIC_NUMBER_MINOR 110 /* 0...n */
/**
* Determine if the server's current MODULE_MAGIC_NUMBER is at least a
Modified: httpd/httpd/branches/2.4.x/include/mpm_common.h
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/include/mpm_common.h?rev=1892167&r1=1892166&r2=1892167&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/include/mpm_common.h (original)
+++ httpd/httpd/branches/2.4.x/include/mpm_common.h Tue Aug 10 08:43:11 2021
@@ -452,6 +452,15 @@ AP_DECLARE_HOOK(void, suspend_connection
AP_DECLARE_HOOK(void, resume_connection,
(conn_rec *c, request_rec *r))
+/**
+ * Notification that the child is stopping. If graceful, ongoing
+ * requests will be served.
+ * @param pchild The child pool
+ * @param graceful != 0 iff this is a graceful shutdown.
+ */
+AP_DECLARE_HOOK(void, child_stopping,
+ (apr_pool_t *pchild, int graceful))
+
/* mutex type string for accept mutex, if any; MPMs should use the
* same mutex type for ease of configuration
*/
Modified: httpd/httpd/branches/2.4.x/server/mpm/event/event.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/server/mpm/event/event.c?rev=1892167&r1=1892166&r2=1892167&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/server/mpm/event/event.c (original)
+++ httpd/httpd/branches/2.4.x/server/mpm/event/event.c Tue Aug 10 08:43:11 2021
@@ -630,6 +630,8 @@ static void signal_threads(int mode)
ap_queue_interrupt_all(worker_queue);
close_worker_sockets(); /* forcefully kill all current connections */
}
+
+ ap_run_child_stopping(pchild, mode == ST_GRACEFUL);
}
static int event_query(int query_code, int *result, apr_status_t *rv)
@@ -720,6 +722,10 @@ static void clean_child_exit(int code) _
static void clean_child_exit(int code)
{
retained->mpm->mpm_state = AP_MPMQ_STOPPING;
+ if (terminate_mode == ST_INIT) {
+ ap_run_child_stopping(pchild, 0);
+ }
+
if (pchild) {
apr_pool_destroy(pchild);
}
Modified: httpd/httpd/branches/2.4.x/server/mpm/prefork/prefork.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/server/mpm/prefork/prefork.c?rev=1892167&r1=1892166&r2=1892167&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/server/mpm/prefork/prefork.c (original)
+++ httpd/httpd/branches/2.4.x/server/mpm/prefork/prefork.c Tue Aug 10 08:43:11 2021
@@ -223,6 +223,10 @@ static void clean_child_exit(int code)
apr_signal(SIGHUP, SIG_IGN);
apr_signal(SIGTERM, SIG_IGN);
+ if (code == 0) {
+ ap_run_child_stopping(pchild, 0);
+ }
+
if (pchild) {
apr_pool_destroy(pchild);
}
Modified: httpd/httpd/branches/2.4.x/server/mpm/worker/worker.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/server/mpm/worker/worker.c?rev=1892167&r1=1892166&r2=1892167&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/server/mpm/worker/worker.c (original)
+++ httpd/httpd/branches/2.4.x/server/mpm/worker/worker.c Tue Aug 10 08:43:11 2021
@@ -324,6 +324,8 @@ static void signal_threads(int mode)
ap_queue_interrupt_all(worker_queue);
close_worker_sockets(); /* forcefully kill all current connections */
}
+
+ ap_run_child_stopping(pchild, mode == ST_GRACEFUL);
}
static int worker_query(int query_code, int *result, apr_status_t *rv)
@@ -432,6 +434,10 @@ static void clean_child_exit(int code) _
static void clean_child_exit(int code)
{
retained->mpm->mpm_state = AP_MPMQ_STOPPING;
+ if (terminate_mode == ST_INIT) {
+ ap_run_child_stopping(pchild, 0);
+ }
+
if (pchild) {
apr_pool_destroy(pchild);
}
Modified: httpd/httpd/branches/2.4.x/server/mpm_common.c
URL: http://svn.apache.org/viewvc/httpd/httpd/branches/2.4.x/server/mpm_common.c?rev=1892167&r1=1892166&r2=1892167&view=diff
==============================================================================
--- httpd/httpd/branches/2.4.x/server/mpm_common.c (original)
+++ httpd/httpd/branches/2.4.x/server/mpm_common.c Tue Aug 10 08:43:11 2021
@@ -72,7 +72,8 @@
APR_HOOK_LINK(end_generation) \
APR_HOOK_LINK(child_status) \
APR_HOOK_LINK(suspend_connection) \
- APR_HOOK_LINK(resume_connection)
+ APR_HOOK_LINK(resume_connection) \
+ APR_HOOK_LINK(child_stopping)
#if AP_ENABLE_EXCEPTION_HOOK
APR_HOOK_STRUCT(
@@ -112,6 +113,9 @@ AP_IMPLEMENT_HOOK_VOID(suspend_connectio
AP_IMPLEMENT_HOOK_VOID(resume_connection,
(conn_rec *c, request_rec *r),
(c, r))
+AP_IMPLEMENT_HOOK_VOID(child_stopping,
+ (apr_pool_t *pchild, int graceful),
+ (pchild, graceful))
/* hooks with no args are implemented last, after disabling APR hook probes */
#if defined(APR_HOOK_PROBES_ENABLED)