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 2022/02/24 11:53:53 UTC

svn commit: r1898369 - in /httpd/httpd/trunk: changes-entries/mpm_child_stopped.txt include/ap_mmn.h include/mpm_common.h server/mpm/event/event.c server/mpm/prefork/prefork.c server/mpm/winnt/child.c server/mpm/worker/worker.c server/mpm_common.c

Author: icing
Date: Thu Feb 24 11:53:53 2022
New Revision: 1898369

URL: http://svn.apache.org/viewvc?rev=1898369&view=rev
Log:
  * core/mpm: add hook 'child_stopped` that gets called when the MPM has
    stopped all processing in a child process. This is when all running
    threads shall be stopped and joined.
    [Stefan Eissing]


Added:
    httpd/httpd/trunk/changes-entries/mpm_child_stopped.txt
Modified:
    httpd/httpd/trunk/include/ap_mmn.h
    httpd/httpd/trunk/include/mpm_common.h
    httpd/httpd/trunk/server/mpm/event/event.c
    httpd/httpd/trunk/server/mpm/prefork/prefork.c
    httpd/httpd/trunk/server/mpm/winnt/child.c
    httpd/httpd/trunk/server/mpm/worker/worker.c
    httpd/httpd/trunk/server/mpm_common.c

Added: httpd/httpd/trunk/changes-entries/mpm_child_stopped.txt
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/changes-entries/mpm_child_stopped.txt?rev=1898369&view=auto
==============================================================================
--- httpd/httpd/trunk/changes-entries/mpm_child_stopped.txt (added)
+++ httpd/httpd/trunk/changes-entries/mpm_child_stopped.txt Thu Feb 24 11:53:53 2022
@@ -0,0 +1,5 @@
+  * core/mpm: add hook 'child_stopped` that gets called when the MPM has
+    stopped all processing in a child process. This is when all running
+    threads shall be stopped and joined.
+    [Stefan Eissing]
+

Modified: httpd/httpd/trunk/include/ap_mmn.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/ap_mmn.h?rev=1898369&r1=1898368&r2=1898369&view=diff
==============================================================================
--- httpd/httpd/trunk/include/ap_mmn.h (original)
+++ httpd/httpd/trunk/include/ap_mmn.h Thu Feb 24 11:53:53 2022
@@ -700,6 +700,8 @@
  *                         add PROXY_WORKER_UDS_PATH_SIZE.
  * 20211221.3 (2.5.1-dev)  Add ap_thread_create(), ap_thread_main_create()
  *                         and ap_thread_current()
+ * 20211221.4 (2.5.1-dev)  Add hook child_stopped to get informed that a child
+ *                         has stopped processing any requests.
  *
  */
 
@@ -708,7 +710,7 @@
 #ifndef MODULE_MAGIC_NUMBER_MAJOR
 #define MODULE_MAGIC_NUMBER_MAJOR 20211221
 #endif
-#define MODULE_MAGIC_NUMBER_MINOR 3             /* 0...n */
+#define MODULE_MAGIC_NUMBER_MINOR 4             /* 0...n */
 
 /**
  * Determine if the server's current MODULE_MAGIC_NUMBER is at least a

Modified: httpd/httpd/trunk/include/mpm_common.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/mpm_common.h?rev=1898369&r1=1898368&r2=1898369&view=diff
==============================================================================
--- httpd/httpd/trunk/include/mpm_common.h (original)
+++ httpd/httpd/trunk/include/mpm_common.h Thu Feb 24 11:53:53 2022
@@ -512,14 +512,30 @@ 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.
+ * Notification that the child is stopping. No new requests
+ * or other tasks to be started.
+ * If graceful, already started requests/tasks should be
+ * processed normally.
  * @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))
 
+/**
+ * Notification that the child has stopped processing
+ * requests completely. Any running threads should be
+ * shut down now.
+ * Ideally, when this hook completes, no more threads
+ * are running in the child process.
+ * Note that de-allocation of global resources should
+ * be run via memory pool destroy callback after this.
+ * @param pchild The child pool
+ * @param graceful != 0 iff this is a graceful shutdown.
+ */
+AP_DECLARE_HOOK(void, child_stopped,
+                (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/trunk/server/mpm/event/event.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/event/event.c?rev=1898369&r1=1898368&r2=1898369&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/event/event.c (original)
+++ httpd/httpd/trunk/server/mpm/event/event.c Thu Feb 24 11:53:53 2022
@@ -775,6 +775,7 @@ static void clean_child_exit(int code)
     }
 
     if (pchild) {
+        ap_run_child_stopped(pchild, terminate_mode == ST_GRACEFUL);
         apr_pool_destroy(pchild);
     }
 

Modified: httpd/httpd/trunk/server/mpm/prefork/prefork.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/prefork/prefork.c?rev=1898369&r1=1898368&r2=1898369&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/prefork/prefork.c (original)
+++ httpd/httpd/trunk/server/mpm/prefork/prefork.c Thu Feb 24 11:53:53 2022
@@ -230,6 +230,7 @@ static void clean_child_exit(int code)
     }
 
     if (pchild) {
+        ap_run_child_stopped(pchild, 0);
         apr_pool_destroy(pchild);
         /*
          * Be safe in case someone still uses afterwards or we get here again.

Modified: httpd/httpd/trunk/server/mpm/winnt/child.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/winnt/child.c?rev=1898369&r1=1898368&r2=1898369&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/winnt/child.c (original)
+++ httpd/httpd/trunk/server/mpm/winnt/child.c Thu Feb 24 11:53:53 2022
@@ -1262,6 +1262,8 @@ void child_main(apr_pool_t *pconf, DWORD
     ap_log_error(APLOG_MARK, APLOG_NOTICE, APR_SUCCESS, ap_server_conf, APLOGNO(00364)
                  "Child: All worker threads have exited.");
 
+    ap_run_child_stopped(pchild, graceful_shutdown);
+
     apr_thread_mutex_destroy(child_lock);
     apr_thread_mutex_destroy(ctxpool_lock);
     CloseHandle(ctxpool_wait_event);

Modified: httpd/httpd/trunk/server/mpm/worker/worker.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/worker/worker.c?rev=1898369&r1=1898368&r2=1898369&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/worker/worker.c (original)
+++ httpd/httpd/trunk/server/mpm/worker/worker.c Thu Feb 24 11:53:53 2022
@@ -443,6 +443,7 @@ static void clean_child_exit(int code)
     }
 
     if (pchild) {
+        ap_run_child_stopped(pchild, terminate_mode == ST_GRACEFUL);
         apr_pool_destroy(pchild);
     }
 

Modified: httpd/httpd/trunk/server/mpm_common.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm_common.c?rev=1898369&r1=1898368&r2=1898369&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm_common.c (original)
+++ httpd/httpd/trunk/server/mpm_common.c Thu Feb 24 11:53:53 2022
@@ -78,7 +78,8 @@
     APR_HOOK_LINK(input_pending) \
     APR_HOOK_LINK(suspend_connection) \
     APR_HOOK_LINK(resume_connection) \
-    APR_HOOK_LINK(child_stopping)
+    APR_HOOK_LINK(child_stopping) \
+    APR_HOOK_LINK(child_stopped)
 
 #if AP_ENABLE_EXCEPTION_HOOK
 APR_HOOK_STRUCT(
@@ -140,6 +141,9 @@ AP_IMPLEMENT_HOOK_VOID(resume_connection
 AP_IMPLEMENT_HOOK_VOID(child_stopping,
                        (apr_pool_t *pchild, int graceful),
                        (pchild, graceful))
+AP_IMPLEMENT_HOOK_VOID(child_stopped,
+                       (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)