]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-114271: Make `thread._rlock` thread-safe in free-threaded builds (#115102)
authormpage <mpage@meta.com>
Fri, 16 Feb 2024 18:29:25 +0000 (10:29 -0800)
committerGitHub <noreply@github.com>
Fri, 16 Feb 2024 18:29:25 +0000 (13:29 -0500)
commitf366e215044e348659df814c27bf70e78907df21
tree046a35e45d76f4db71825d63849009912fce0ea0
parent13addd2bbdcbf96c5ea26a0f425c049f1b71e945
gh-114271: Make `thread._rlock` thread-safe in free-threaded builds (#115102)

The ID of the owning thread (`rlock_owner`) may be accessed by
multiple threads without holding the underlying lock; relaxed
atomics are used in place of the previous loads/stores.

The number of times that the lock has been acquired (`rlock_count`)
is only ever accessed by the thread that holds the lock; we do not
need to use atomics to access it.
Include/cpython/pyatomic.h
Include/cpython/pyatomic_gcc.h
Include/cpython/pyatomic_msc.h
Include/cpython/pyatomic_std.h
Modules/_threadmodule.c