summaryrefslogtreecommitdiff
path: root/Python/sysmodule.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-03-07 00:24:23 +0100
committerGitHub <noreply@github.com>2020-03-07 00:24:23 +0100
commit7b3c252dc7f44d4bdc4c7c82d225ebd09c78f520 (patch)
tree39b9496171733c94644e7a2671878fc3452526b8 /Python/sysmodule.c
parent557287075c264d2458cd3e1b45e9b8ee5341e0a1 (diff)
downloadcpython-git-7b3c252dc7f44d4bdc4c7c82d225ebd09c78f520.tar.gz
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/sysmodule.c')
-rw-r--r--Python/sysmodule.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index bfacf314df..f086514a03 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -289,8 +289,9 @@ _PySys_ClearAuditHooks(void)
/* Must be finalizing to clear hooks */
_PyRuntimeState *runtime = &_PyRuntime;
PyThreadState *ts = _PyRuntimeState_GetThreadState(runtime);
- assert(!ts || _Py_CURRENTLY_FINALIZING(runtime, ts));
- if (!ts || !_Py_CURRENTLY_FINALIZING(runtime, ts)) {
+ PyThreadState *finalizing = _PyRuntimeState_GetFinalizing(runtime);
+ assert(!ts || finalizing == ts);
+ if (!ts || finalizing != ts) {
return;
}