bpo-40232: Update PyOS_AfterFork_Child() to use _PyThread_at_fork_reinit() (GH-19450)

This commit is contained in:
Dong-hee Na 2020-04-15 01:16:24 +09:00 committed by GitHub
parent e5014be049
commit 62f75fe3dd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 21 additions and 13 deletions

View file

@ -397,6 +397,7 @@ PyEval_ReleaseThread(PyThreadState *tstate)
drop_gil(&runtime->ceval, tstate);
}
#ifdef HAVE_FORK
/* This function is called from PyOS_AfterFork_Child to destroy all threads
* which are not running in the child process, and clear internal locks
* which might be held by those threads.
@ -416,14 +417,14 @@ _PyEval_ReInitThreads(_PyRuntimeState *runtime)
take_gil(tstate);
struct _pending_calls *pending = &tstate->interp->ceval.pending;
pending->lock = PyThread_allocate_lock();
if (pending->lock == NULL) {
if (_PyThread_at_fork_reinit(&pending->lock) < 0) {
Py_FatalError("Can't initialize threads for pending calls");
}
/* Destroy all threads except the current one */
_PyThreadState_DeleteExcept(runtime, tstate);
}
#endif
/* This function is used to signal that async exceptions are waiting to be
raised. */