bpo-30395 _PyGILState_Reinit deadlock fix (#1734)

head_lock could be held by another thread when fork happened. We should
reset it to avoid deadlock.
This commit is contained in:
Jason Fried 2017-05-22 16:58:55 -07:00 committed by Łukasz Langa
parent 1b9530c536
commit f82c951d1c
2 changed files with 5 additions and 0 deletions

View file

@ -744,6 +744,10 @@ _PyGILState_Fini(void)
void
_PyGILState_Reinit(void)
{
#ifdef WITH_THREAD
head_mutex = NULL;
HEAD_INIT();
#endif
PyThreadState *tstate = PyGILState_GetThisThreadState();
PyThread_delete_key(autoTLSkey);
if ((autoTLSkey = PyThread_create_key()) == -1)