]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Backport r42314 which fixed Windows breakage when checking that socket
authorNeal Norwitz <nnorwitz@gmail.com>
Sun, 12 Feb 2006 21:07:17 +0000 (21:07 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Sun, 12 Feb 2006 21:07:17 +0000 (21:07 +0000)
descriptors fit in fd_set.

Introduce Py_SOCKET_FD_CAN_BE_GE_FD_SETSIZE.
Proposed by Tim Peters implemented by Martin von Loewis.

Modules/_ssl.c
Modules/socketmodule.c
PC/pyconfig.h

index 23e7538e7817deb4288853d1c9fdb49956f363a1..fdfaabcd437827ab4e75a4143083a72b151ab33e 100644 (file)
@@ -377,8 +377,10 @@ check_socket_and_wait_for_timeout(PySocketSockObject *s, int writing)
                return SOCKET_HAS_BEEN_CLOSED;
 
        /* Guard against socket too large for select*/
+#ifndef Py_SOCKET_FD_CAN_BE_GE_FD_SETSIZE
        if (s->sock_fd >= FD_SETSIZE)
                return SOCKET_INVALID;
+#endif
 
        /* Construct the arguments to select */
        tv.tv_sec = (int)s->sock_timeout;
index e0af01aa00c0ae38d00f623bcd5d4fd7e909943b..0efa9479405d51caa0757639d0d242d236388a37 100644 (file)
@@ -391,7 +391,14 @@ static int taskwindow;
 static PyTypeObject sock_type;
 
 /* 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)
+#endif
 
 static PyObject*
 select_error(void)
index 1979b7e023bb70d660a38380b68a8ddf3d995efe..793fbed1a47878f2ff7ae75f977dd5c74c38fbd0 100644 (file)
@@ -562,4 +562,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).  */
 /* #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 */