You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by yl...@apache.org on 2018/01/29 17:00:23 UTC

svn commit: r1822537 - /httpd/httpd/trunk/os/unix/unixd.c

Author: ylavic
Date: Mon Jan 29 17:00:23 2018
New Revision: 1822537

URL: http://svn.apache.org/viewvc?rev=1822537&view=rev
Log:
mpm_unix(es): cleanup properly on exit in one_process mode.

We can destroy ap_pglobal in the MPMs because clean_child_exit() runs in
a DSO which would be unloaded under us.

So we defer an ap_terminate() with atexit() in ap_unixd_mpm_set_signals(),
all this is static/builtin code in "os/unix/unixd.c".


Modified:
    httpd/httpd/trunk/os/unix/unixd.c

Modified: httpd/httpd/trunk/os/unix/unixd.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/os/unix/unixd.c?rev=1822537&r1=1822536&r2=1822537&view=diff
==============================================================================
--- httpd/httpd/trunk/os/unix/unixd.c (original)
+++ httpd/httpd/trunk/os/unix/unixd.c Mon Jan 29 17:00:23 2018
@@ -18,6 +18,7 @@
 #include "httpd.h"
 #include "http_config.h"
 #include "http_main.h"
+#include "http_core.h"
 #include "http_log.h"
 #include "unixd.h"
 #include "mpm_common.h"
@@ -515,6 +516,13 @@ static apr_status_t unset_signals(void *
     return APR_SUCCESS;
 }
 
+static void ap_terminate(void)
+{
+    ap_main_state = AP_SQ_MS_EXITING;
+    apr_pool_destroy(ap_pglobal);
+    apr_terminate();
+}
+
 AP_DECLARE(void) ap_unixd_mpm_set_signals(apr_pool_t *pconf, int one_process)
 {
 #ifndef NO_USE_SIGACTION
@@ -524,6 +532,13 @@ AP_DECLARE(void) ap_unixd_mpm_set_signal
     if (!one_process) {
         ap_fatal_signal_setup(ap_server_conf, pconf);
     }
+    else {
+        static int once = 0;
+        if (!once) {
+            atexit(ap_terminate);
+            once = 1;
+        }
+    }
 
     /* Signals' handlers depend on retained data */
     (void)ap_unixd_mpm_get_retained_data();