summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorCharles-François Natali <neologix@free.fr>2012-02-02 19:31:42 (GMT)
committerCharles-François Natali <neologix@free.fr>2012-02-02 19:31:42 (GMT)
commit6d0d24e359b6d8a72a20c2091bbea0e16170d767 (patch)
treed7e06c5c3f4c289553ecf4a4a79521b4c8967f7f /Modules
parent03c29f90c37870d3a0a65524373acb5008fa7a11 (diff)
downloadcpython-6d0d24e359b6d8a72a20c2091bbea0e16170d767.zip
cpython-6d0d24e359b6d8a72a20c2091bbea0e16170d767.tar.gz
cpython-6d0d24e359b6d8a72a20c2091bbea0e16170d767.tar.bz2
Issue #13817: After fork(), reinit the ad-hoc TLS implementation earlier to fix
a random deadlock when fork() is called in a multithreaded process in debug mode, and make PyOS_AfterFork() more robust.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/signalmodule.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c
index 87c1c9a..32cd8bb 100644
--- a/Modules/signalmodule.c
+++ b/Modules/signalmodule.c
@@ -991,11 +991,13 @@ void
PyOS_AfterFork(void)
{
#ifdef WITH_THREAD
+ /* PyThread_ReInitTLS() must be called early, to make sure that the TLS API
+ * can be called safely. */
+ PyThread_ReInitTLS();
_PyGILState_Reinit();
PyEval_ReInitThreads();
main_thread = PyThread_get_thread_ident();
main_pid = getpid();
_PyImport_ReInitLock();
- PyThread_ReInitTLS();
#endif
}