Skip to content

Commit 2d82ab7

Browse files
gh-132886: use relaxed atomics for sock_fd in gil builds in socket module (#133208)
1 parent 7d129f9 commit 2d82ab7

File tree

1 file changed

+0
-9
lines changed

1 file changed

+0
-9
lines changed

Modules/socketmodule.c

-9
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ Local naming conventions:
111111
#include "pycore_moduleobject.h" // _PyModule_GetState
112112
#include "pycore_time.h" // _PyTime_AsMilliseconds()
113113
#include "pycore_pystate.h" // _Py_AssertHoldsTstate()
114-
#include "pycore_pyatomic_ft_wrappers.h"
115114

116115
#ifdef _Py_MEMORY_SANITIZER
117116
# include <sanitizer/msan_interface.h>
@@ -565,7 +564,6 @@ static int sock_cloexec_works = -1;
565564
static inline void
566565
set_sock_fd(PySocketSockObject *s, SOCKET_T fd)
567566
{
568-
#ifdef Py_GIL_DISABLED
569567
#if SIZEOF_SOCKET_T == SIZEOF_INT
570568
_Py_atomic_store_int_relaxed((int *)&s->sock_fd, (int)fd);
571569
#elif SIZEOF_SOCKET_T == SIZEOF_LONG
@@ -575,15 +573,11 @@ set_sock_fd(PySocketSockObject *s, SOCKET_T fd)
575573
#else
576574
#error "Unsupported SIZEOF_SOCKET_T"
577575
#endif
578-
#else
579-
s->sock_fd = fd;
580-
#endif
581576
}
582577

583578
static inline SOCKET_T
584579
get_sock_fd(PySocketSockObject *s)
585580
{
586-
#ifdef Py_GIL_DISABLED
587581
#if SIZEOF_SOCKET_T == SIZEOF_INT
588582
return (SOCKET_T)_Py_atomic_load_int_relaxed((int *)&s->sock_fd);
589583
#elif SIZEOF_SOCKET_T == SIZEOF_LONG
@@ -593,9 +587,6 @@ get_sock_fd(PySocketSockObject *s)
593587
#else
594588
#error "Unsupported SIZEOF_SOCKET_T"
595589
#endif
596-
#else
597-
return s->sock_fd;
598-
#endif
599590
}
600591

601592
#define _PySocketSockObject_CAST(op) ((PySocketSockObject *)(op))

0 commit comments

Comments
 (0)