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.
This commit is contained in:
Charles-François Natali 2012-02-02 20:31:42 +01:00
parent 03c29f90c3
commit 6d0d24e359
2 changed files with 26 additions and 1 deletions

View file

@ -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
}