8000 PyOS_AfterFork_Child() pass tstate to _PyEval_ReInitThreads() by vstinner · Pull Request #20598 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

PyOS_AfterFork_Child() pass tstate to _PyEval_ReInitThreads() #20598

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Include/internal/pycore_ceval.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ PyAPI_FUNC(int) _PyEval_AddPendingCall(
void *arg);
PyAPI_FUNC(void) _PyEval_SignalAsyncExc(PyThreadState *tstate);
#ifdef HAVE_FORK
extern PyStatus _PyEval_ReInitThreads(struct pyruntimestate *runtime);
extern PyStatus _PyEval_ReInitThreads(PyThreadState *tstate);
#endif
PyAPI_FUNC(void) _PyEval_SetCoroutineOriginTrackingDepth(
PyThreadState *tstate,
Expand Down
8 changes: 6 additions & 2 deletions Modules/posixmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,10 @@ PyOS_AfterFork_Child(void)
goto fatal_error;
}

status = _PyEval_ReInitThreads(runtime);
PyThreadState *tstate = _PyThreadState_GET();
_Py_EnsureTstateNotNULL(tstate);

status = _PyEval_ReInitThreads(tstate);
if (_PyStatus_EXCEPTION(status)) {
goto fatal_error;
}
Expand All @@ -491,8 +494,9 @@ PyOS_AfterFork_Child(void)
if (_PyStatus_EXCEPTION(status)) {
goto fatal_error;
}
assert(_PyThreadState_GET() == tstate);

run_at_forkers(_PyInterpreterState_GET()->after_forkers_child, 0);
run_at_forkers(tstate->interp->after_forkers_child, 0);
return;

fatal_error:
Expand Down
5 changes: 2 additions & 3 deletions Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -436,10 +436,9 @@ PyEval_ReleaseThread(PyThreadState *tstate)
which are not running in the child process, and clear internal locks
which might be held by those threads. */
PyStatus
_PyEval_ReInitThreads(_PyRuntimeState *runtime)
_PyEval_ReInitThreads(PyThreadState *tstate)
{
PyThreadState *tstate = _PyRuntimeState_GetThreadState(runtime);
_Py_EnsureTstateNotNULL(tstate);
_PyRuntimeState *runtime = tstate->interp->runtime;

#ifdef EXPERIMENTAL_ISOLATED_SUBINTERPRETERS
struct _gil_runtime_state *gil = &tstate->interp->ceval.gil;
Expand Down
0