[omd-commits] OMD Git: omd: mod_python: fix shutdown bug

git version control git at mathias-kettner.de
Wed Dec 21 17:11:33 CET 2011


Module:   omd
Branch:   master
Commit:   5cb17c4b593848c0d18d700a33d4bfaafffb3ab5
URL:      http://omdistro.org/projects/omd/repository/revisions/5cb17c4b593848c0d18d700a33d4bfaafffb3ab5

Author:   Mathias Kettner <mk at mathias-kettner.de>
Date:     Wed Dec 21 17:10:02 2011 +0100
Commiter: Mathias Kettner <mk at mathias-kettner.de>
Date:     Wed Dec 21 17:10:02 2011 +0100

mod_python: fix shutdown bug

---

 .../0005-handle-sigterm-while-in-python.dif        |   33 ++++++++++++++++++++
 packages/mod_python/patches/README                 |   12 ++++++-
 2 files changed, 44 insertions(+), 1 deletions(-)

diff --git a/packages/mod_python/patches/0005-handle-sigterm-while-in-python.dif b/packages/mod_python/patches/0005-handle-sigterm-while-in-python.dif
new file mode 100644
index 0000000..6ebb765
--- /dev/null
+++ b/packages/mod_python/patches/0005-handle-sigterm-while-in-python.dif
@@ -0,0 +1,33 @@
+diff -ru mod_python-3.3.1.orig/src/mod_python.c mod_python-3.3.1/src/mod_python.c
+--- mod_python-3.3.1.orig/src/mod_python.c	2006-11-09 07:21:23.000000000 +0100
++++ mod_python-3.3.1/src/mod_python.c	2011-12-21 16:59:16.171960122 +0100
+@@ -1523,6 +1529,13 @@
+     }
+ }
+ 
++
++int mod_python_got_killed;
++void sig_term_during_python(int s)
++{
++    mod_python_got_killed = 1;
++}
++
+ /**
+  ** python_handler
+  **
+@@ -1649,8 +1662,15 @@
+      * This is the C equivalent of
+      * >>> resultobject = obCallBack.Dispatch(request_object, phase)
+      */
++    mod_python_got_killed = 0;
++    sighandler_t orig_handler = signal(SIGTERM, sig_term_during_python);
+     resultobject = PyObject_CallMethod(idata->obcallback, "HandlerDispatch",
+                                        "O", request_obj);
++    signal(SIGTERM, orig_handler);
++    if (mod_python_got_killed) {
++        ap_log_rerror(APLOG_MARK, APLOG_NOTICE, 0, req, "Got SIGTERM while Python running.");
++        exit(0);
++    }
+ 
+     /* clear phase from request object */
+     Py_XDECREF(request_obj->phase);
diff --git a/packages/mod_python/patches/README b/packages/mod_python/patches/README
index 8cdc417..0facb9d 100644
--- a/packages/mod_python/patches/README
+++ b/packages/mod_python/patches/README
@@ -1,3 +1,13 @@
-These patches are taken with thanks from the FEDORA mod_python
+0004:
+    Prepend /omd/versions/X/lib/python to Python path
+
+0005:
+    Handle the case during stopping of Apache where SIGTERM is
+    received while Python is currently running. Normally mod_python
+    will be caught be the signal and end in a deadlock. The patch
+    ignores the signal until the Python interpreter has exited and
+    simply exit the process afterwards.
+
+The other patches are taken with thanks from the FEDORA mod_python
 package and fix compile problems and RedHat 6.1 (and probably
 other distros as well).



More information about the omd-commits mailing list