Skip to content

Commit d839af0

Browse files
Add state pointer to PySocketSockObject
1 parent 274c412 commit d839af0

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

Modules/socketmodule.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ remove_unusable_flags(PyObject *m)
541541
#define INADDR_NONE (-1)
542542
#endif
543543

544-
typedef struct {
544+
typedef struct _socket_state {
545545
/* The sock_type variable contains pointers to various functions,
546546
some of which call new_sockobject(), which uses sock_type, so
547547
there has to be a circular reference. */
@@ -1052,6 +1052,7 @@ init_sockobject(socket_state *state, PySocketSockObject *s,
10521052
}
10531053
}
10541054
}
1055+
s->state = state;
10551056
return 0;
10561057
}
10571058

Modules/socketmodule.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,8 @@ typedef union sock_addr {
311311
like the address family, which is used to decode socket address
312312
arguments properly. */
313313

314+
struct _socket_state; // Forward decl.
315+
314316
typedef struct {
315317
PyObject_HEAD
316318
SOCKET_T sock_fd; /* Socket file descriptor */
@@ -322,6 +324,7 @@ typedef struct {
322324
sets a Python exception */
323325
_PyTime_t sock_timeout; /* Operation timeout in seconds;
324326
0.0 means non-blocking */
327+
struct _socket_state *state;
325328
} PySocketSockObject;
326329

327330
/* --- C API ----------------------------------------------------*/

0 commit comments

Comments
 (0)