--- /dev/null
+ * 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]
* ap_bucket_wc_create() to util_filter.h
* 20210531.2 (2.5.1-dev) Add ap_proxy_get_worker_ex() and
* ap_proxy_define_worker_ex() to mod_proxy.h
+ * 20210531.3 (2.5.1-dev) Add hook child_stopping to get informed that a child
+ * is being shut down.
*/
#define MODULE_MAGIC_COOKIE 0x41503235UL /* "AP25" */
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
*/
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)
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);
}
static void clean_child_exit(int code) __attribute__ ((noreturn));
static void clean_child_exit(int code)
{
- retained->mpm->mpm_state = AP_MPMQ_STOPPING;
-
apr_signal(SIGHUP, SIG_IGN);
apr_signal(SIGTERM, SIG_IGN);
+ retained->mpm->mpm_state = AP_MPMQ_STOPPING;
+ if (code == 0) {
+ ap_run_child_stopping(pchild, 0);
+ }
+
if (pchild) {
apr_pool_destroy(pchild);
/*
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)
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);
}
APR_HOOK_LINK(output_pending) \
APR_HOOK_LINK(input_pending) \
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(
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)