[Python-checkins] r42314 - in python/trunk: Modules/_ssl.c Modules/socketmodule.c PC/pyconfig.h

martin.v.loewis python-checkins at python.org
Sat Feb 11 10:27:05 CET 2006


Author: martin.v.loewis
Date: Sat Feb 11 10:27:05 2006
New Revision: 42314

Modified:
   python/trunk/Modules/_ssl.c
   python/trunk/Modules/socketmodule.c
   python/trunk/PC/pyconfig.h
Log:
Introduce Py_SOCKET_FD_CAN_BE_GE_FD_SETSIZE. 
Proposed by Tim Peters.

Modified: python/trunk/Modules/_ssl.c
==============================================================================
--- python/trunk/Modules/_ssl.c	(original)
+++ python/trunk/Modules/_ssl.c	Sat Feb 11 10:27:05 2006
@@ -377,8 +377,10 @@
 		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;

Modified: python/trunk/Modules/socketmodule.c
==============================================================================
--- python/trunk/Modules/socketmodule.c	(original)
+++ python/trunk/Modules/socketmodule.c	Sat Feb 11 10:27:05 2006
@@ -396,7 +396,14 @@
 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)

Modified: python/trunk/PC/pyconfig.h
==============================================================================
--- python/trunk/PC/pyconfig.h	(original)
+++ python/trunk/PC/pyconfig.h	Sat Feb 11 10:27:05 2006
@@ -572,4 +572,9 @@
 
 /* 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 */


More information about the Python-checkins mailing list