Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[3.14] gh-132886: use relaxed atomics for sock_fd in gil builds in socket module (GH-133208) #133683

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
May 8, 2025
Merged
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
9 changes: 0 additions & 9 deletions Modules/socketmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ Local naming conventions:
#include "pycore_moduleobject.h" // _PyModule_GetState
#include "pycore_time.h" // _PyTime_AsMilliseconds()
#include "pycore_pystate.h" // _Py_AssertHoldsTstate()
#include "pycore_pyatomic_ft_wrappers.h"

#ifdef _Py_MEMORY_SANITIZER
# include <sanitizer/msan_interface.h>
Expand Down Expand Up @@ -565,7 +564,6 @@ static int sock_cloexec_works = -1;
static inline void
set_sock_fd(PySocketSockObject *s, SOCKET_T fd)
{
#ifdef Py_GIL_DISABLED
#if SIZEOF_SOCKET_T == SIZEOF_INT
_Py_atomic_store_int_relaxed((int *)&s->sock_fd, (int)fd);
#elif SIZEOF_SOCKET_T == SIZEOF_LONG
Expand All @@ -575,15 +573,11 @@ set_sock_fd(PySocketSockObject *s, SOCKET_T fd)
#else
#error "Unsupported SIZEOF_SOCKET_T"
#endif
#else
s->sock_fd = fd;
#endif
}

static inline SOCKET_T
get_sock_fd(PySocketSockObject *s)
{
#ifdef Py_GIL_DISABLED
#if SIZEOF_SOCKET_T == SIZEOF_INT
return (SOCKET_T)_Py_atomic_load_int_relaxed((int *)&s->sock_fd);
#elif SIZEOF_SOCKET_T == SIZEOF_LONG
Expand All @@ -593,9 +587,6 @@ get_sock_fd(PySocketSockObject *s)
#else
#error "Unsupported SIZEOF_SOCKET_T"
#endif
#else
return s->sock_fd;
#endif
}

#define _PySocketSockObject_CAST(op) ((PySocketSockObject *)(op))
Expand Down
Loading