mirror of
https://github.com/python/cpython.git
synced 2025-09-14 20:56:06 +00:00
Introduce Py_SOCKET_FD_CAN_BE_GE_FD_SETSIZE.
Proposed by Tim Peters.
This commit is contained in:
parent
03ca23d892
commit
f84d1b9375
3 changed files with 14 additions and 0 deletions
|
@ -377,8 +377,10 @@ check_socket_and_wait_for_timeout(PySocketSockObject *s, int writing)
|
||||||
return SOCKET_HAS_BEEN_CLOSED;
|
return SOCKET_HAS_BEEN_CLOSED;
|
||||||
|
|
||||||
/* Guard against socket too large for select*/
|
/* Guard against socket too large for select*/
|
||||||
|
#ifndef Py_SOCKET_FD_CAN_BE_GE_FD_SETSIZE
|
||||||
if (s->sock_fd >= FD_SETSIZE)
|
if (s->sock_fd >= FD_SETSIZE)
|
||||||
return SOCKET_INVALID;
|
return SOCKET_INVALID;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Construct the arguments to select */
|
/* Construct the arguments to select */
|
||||||
tv.tv_sec = (int)s->sock_timeout;
|
tv.tv_sec = (int)s->sock_timeout;
|
||||||
|
|
|
@ -396,7 +396,14 @@ static int taskwindow;
|
||||||
static PyTypeObject sock_type;
|
static PyTypeObject sock_type;
|
||||||
|
|
||||||
/* Can we call select() with this socket without a buffer overrun? */
|
/* Can we call select() with this socket without a buffer overrun? */
|
||||||
|
#ifdef Py_SOCKET_FD_CAN_BE_GE_FD_SETSIZE
|
||||||
|
/* Platform can select file descriptors beyond FD_SETSIZE */
|
||||||
|
#define IS_SELECTABLE(s) 1
|
||||||
|
#else
|
||||||
|
/* POSIX says selecting file descriptors beyond FD_SETSIZE
|
||||||
|
has undefined behaviour. */
|
||||||
#define IS_SELECTABLE(s) ((s)->sock_fd < FD_SETSIZE)
|
#define IS_SELECTABLE(s) ((s)->sock_fd < FD_SETSIZE)
|
||||||
|
#endif
|
||||||
|
|
||||||
static PyObject*
|
static PyObject*
|
||||||
select_error(void)
|
select_error(void)
|
||||||
|
|
|
@ -572,4 +572,9 @@ Py_NO_ENABLE_SHARED to find out. Also support MS_NO_COREDLL for b/w compat */
|
||||||
|
|
||||||
/* Define if you have the thread library (-lthread). */
|
/* Define if you have the thread library (-lthread). */
|
||||||
/* #undef HAVE_LIBTHREAD */
|
/* #undef HAVE_LIBTHREAD */
|
||||||
|
|
||||||
|
/* WinSock does not use a bitmask in select, and uses
|
||||||
|
socket handles greater than FD_SETSIZE */
|
||||||
|
#define Py_SOCKET_FD_CAN_BE_GE_FD_SETSIZE
|
||||||
|
|
||||||
#endif /* !Py_CONFIG_H */
|
#endif /* !Py_CONFIG_H */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue