summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorJesse Noller <jnoller@gmail.com>2008-07-16 20:03:47 (GMT)
committerJesse Noller <jnoller@gmail.com>2008-07-16 20:03:47 (GMT)
commit5e62ca4fea04ad7b349330c50dc11937ab3278f4 (patch)
tree3a37b08db904d9e9239b7d08f630f24c46569a61 /Python
parent1bbf4ea553a5089ec82377dd24531dd79e3357c6 (diff)
downloadcpython-5e62ca4fea04ad7b349330c50dc11937ab3278f4.zip
cpython-5e62ca4fea04ad7b349330c50dc11937ab3278f4.tar.gz
cpython-5e62ca4fea04ad7b349330c50dc11937ab3278f4.tar.bz2
Apply patch for 874900: threading module can deadlock after fork
Diffstat (limited to 'Python')
-rw-r--r--Python/ceval.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index a9e37ae..f61bcd5 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -274,6 +274,9 @@ PyEval_ReleaseThread(PyThreadState *tstate)
void
PyEval_ReInitThreads(void)
{
+ PyObject *threading, *result;
+ PyThreadState *tstate;
+
if (!interpreter_lock)
return;
/*XXX Can't use PyThread_free_lock here because it does too
@@ -283,6 +286,23 @@ PyEval_ReInitThreads(void)
interpreter_lock = PyThread_allocate_lock();
PyThread_acquire_lock(interpreter_lock, 1);
main_thread = PyThread_get_thread_ident();
+
+ /* Update the threading module with the new state.
+ */
+ tstate = PyThreadState_GET();
+ threading = PyMapping_GetItemString(tstate->interp->modules,
+ "threading");
+ if (threading == NULL) {
+ /* threading not imported */
+ PyErr_Clear();
+ return;
+ }
+ result = PyObject_CallMethod(threading, "_after_fork", NULL);
+ if (result == NULL)
+ PyErr_WriteUnraisable(threading);
+ else
+ Py_DECREF(result);
+ Py_DECREF(threading);
}
#endif