diff options
author | Victor Stinner <vstinner@python.org> | 2020-03-06 23:24:23 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-06 23:24:23 (GMT) |
commit | 7b3c252dc7f44d4bdc4c7c82d225ebd09c78f520 (patch) | |
tree | 39b9496171733c94644e7a2671878fc3452526b8 /Python/ceval.c | |
parent | 557287075c264d2458cd3e1b45e9b8ee5341e0a1 (diff) | |
download | cpython-7b3c252dc7f44d4bdc4c7c82d225ebd09c78f520.zip cpython-7b3c252dc7f44d4bdc4c7c82d225ebd09c78f520.tar.gz cpython-7b3c252dc7f44d4bdc4c7c82d225ebd09c78f520.tar.bz2 |
bpo-39877: _PyRuntimeState.finalizing becomes atomic (GH-18816)
Convert _PyRuntimeState.finalizing field to an atomic variable:
* Rename it to _finalizing
* Change its type to _Py_atomic_address
* Add _PyRuntimeState_GetFinalizing() and _PyRuntimeState_SetFinalizing()
functions
* Remove _Py_CURRENTLY_FINALIZING() function: replace it with testing
directly _PyRuntimeState_GetFinalizing() value
Convert _PyRuntimeState_GetThreadState() to static inline function.
Diffstat (limited to 'Python/ceval.c')
-rw-r--r-- | Python/ceval.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index ef4aac2..20e32e2 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -240,7 +240,8 @@ exit_thread_if_finalizing(PyThreadState *tstate) { _PyRuntimeState *runtime = tstate->interp->runtime; /* _Py_Finalizing is protected by the GIL */ - if (runtime->finalizing != NULL && !_Py_CURRENTLY_FINALIZING(runtime, tstate)) { + PyThreadState *finalizing = _PyRuntimeState_GetFinalizing(runtime); + if (finalizing != NULL && finalizing != tstate) { drop_gil(&runtime->ceval, tstate); PyThread_exit_thread(); } |