f474496
From 0f34844009075391c55419a3afb90e469facf35e Mon Sep 17 00:00:00 2001
f474496
From: Graham Dumpleton <Graham.Dumpleton@gmail.com>
f474496
Date: Tue, 14 May 2019 16:14:07 +1000
f474496
Subject: [PATCH] Changed functions to pre/post actions when forking.
f474496
f474496
---
f474496
 src/server/mod_wsgi.c | 13 ++++++++++++-
f474496
 1 file changed, 12 insertions(+), 1 deletion(-)
f474496
f474496
diff --git a/src/server/mod_wsgi.c b/src/server/mod_wsgi.c
f474496
index 2e4bb24..bf55945 100644
f474496
--- a/src/server/mod_wsgi.c
f474496
+++ b/src/server/mod_wsgi.c
f474496
@@ -4345,8 +4345,13 @@ static void wsgi_python_child_init(apr_pool_t *p)
f474496
      * do it if Python was initialised in parent process.
f474496
      */
f474496
 
f474496
-    if (wsgi_python_initialized && !wsgi_python_after_fork)
f474496
+    if (wsgi_python_initialized && !wsgi_python_after_fork) {
f474496
+#if PY_MAJOR_VERSION > 3 || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 7)
f474496
+        PyOS_AfterFork_Child();
f474496
+#else
f474496
         PyOS_AfterFork();
f474496
+#endif
f474496
+    }
f474496
 
f474496
     /* Finalise any Python objects required by child process. */
f474496
 
f474496
@@ -10422,6 +10427,12 @@ static int wsgi_start_process(apr_pool_t *p, WSGIDaemonProcess *daemon)
f474496
         wsgi_exit_daemon_process(0);
f474496
     }
f474496
 
f474496
+    if (wsgi_python_initialized) {
f474496
+#if PY_MAJOR_VERSION > 3 || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 7)
f474496
+        PyOS_AfterFork_Parent();
f474496
+#endif
f474496
+    }
f474496
+
f474496
     apr_pool_note_subprocess(p, &daemon->process, APR_KILL_AFTER_TIMEOUT);
f474496
     apr_proc_other_child_register(&daemon->process, wsgi_manage_process,
f474496
                                   daemon, NULL, p);