diff options
author | mpage <mpage@meta.com> | 2024-04-08 14:58:38 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-08 14:58:38 (GMT) |
commit | df7317904849a41d51db39d92c5d431a18e22637 (patch) | |
tree | e7dddcb5006cb6f50b9f47477217043157a42e01 /Modules/_ssl | |
parent | e16062dd3428a5846344e0a8c6ee2f352d34ce1b (diff) | |
download | cpython-df7317904849a41d51db39d92c5d431a18e22637.zip cpython-df7317904849a41d51db39d92c5d431a18e22637.tar.gz cpython-df7317904849a41d51db39d92c5d431a18e22637.tar.bz2 |
gh-111926: Make weakrefs thread-safe in free-threaded builds (#117168)
Most mutable data is protected by a striped lock that is keyed on the
referenced object's address. The weakref's hash is protected using the
weakref's per-object lock.
Note that this only affects free-threaded builds. Apart from some minor
refactoring, the added code is all either gated by `ifdef`s or is a no-op
(e.g. `Py_BEGIN_CRITICAL_SECTION`).
Diffstat (limited to 'Modules/_ssl')
-rw-r--r-- | Modules/_ssl/debughelpers.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Modules/_ssl/debughelpers.c b/Modules/_ssl/debughelpers.c index 07e9ce7..9c87f8b 100644 --- a/Modules/_ssl/debughelpers.c +++ b/Modules/_ssl/debughelpers.c @@ -28,12 +28,12 @@ _PySSL_msg_callback(int write_p, int version, int content_type, PyObject *ssl_socket; /* ssl.SSLSocket or ssl.SSLObject */ if (ssl_obj->owner) - ssl_socket = _PyWeakref_GET_REF(ssl_obj->owner); + PyWeakref_GetRef(ssl_obj->owner, &ssl_socket); else if (ssl_obj->Socket) - ssl_socket = _PyWeakref_GET_REF(ssl_obj->Socket); + PyWeakref_GetRef(ssl_obj->Socket, &ssl_socket); else ssl_socket = (PyObject *)Py_NewRef(ssl_obj); - assert(ssl_socket != NULL); // _PyWeakref_GET_REF() can return NULL + assert(ssl_socket != NULL); // PyWeakref_GetRef() can return NULL /* assume that OpenSSL verifies all payload and buf len is of sufficient length */ |