summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1998-07-02 02:53:36 (GMT)
committerGuido van Rossum <guido@python.org>1998-07-02 02:53:36 (GMT)
commitd20781b5184420df596881bf630d925478729b69 (patch)
tree5659e77916a06eaa777fb8917631b4869384dde3 /Modules
parent030eb118238c6def2cd2ee7ec5508c66f7f240c0 (diff)
downloadcpython-d20781b5184420df596881bf630d925478729b69.zip
cpython-d20781b5184420df596881bf630d925478729b69.tar.gz
cpython-d20781b5184420df596881bf630d925478729b69.tar.bz2
On Windows, put the select file descriptor arrays on the heap.
This is because they are huge and the stack is limited on Windows. Other platforms keep declaring it on the stack.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/selectmodule.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c
index dc3b521..3913181 100644
--- a/Modules/selectmodule.c
+++ b/Modules/selectmodule.c
@@ -215,9 +215,14 @@ select_select(self, args)
PyObject *self;
PyObject *args;
{
+#ifdef MS_WINDOWS
+ /* This would be an awful lot of stack space on Windows! */
+ pylist *rfd2obj, *wfd2obj, *efd2obj;
+#else
pylist rfd2obj[FD_SETSIZE + 3];
pylist wfd2obj[FD_SETSIZE + 3];
pylist efd2obj[FD_SETSIZE + 3];
+#endif
PyObject *ifdlist, *ofdlist, *efdlist;
PyObject *ret = NULL;
PyObject *tout = Py_None;
@@ -258,6 +263,18 @@ select_select(self, args)
return NULL;
}
+#ifdef MS_WINDOWS
+ /* Allocate memory for the lists */
+ rfd2obj = PyMem_NEW(pylist, FD_SETSIZE + 3);
+ wfd2obj = PyMem_NEW(pylist, FD_SETSIZE + 3);
+ efd2obj = PyMem_NEW(pylist, FD_SETSIZE + 3);
+ if (rfd2obj == NULL || wfd2obj == NULL || efd2obj == NULL) {
+ PyMem_XDEL(rfd2obj);
+ PyMem_XDEL(wfd2obj);
+ PyMem_XDEL(efd2obj);
+ return NULL;
+ }
+#endif
/* Convert lists to fd_sets, and get maximum fd number
* propagates the Python exception set in list2set()
*/
@@ -311,6 +328,11 @@ select_select(self, args)
reap_obj(rfd2obj);
reap_obj(wfd2obj);
reap_obj(efd2obj);
+#ifdef MS_WINDOWS
+ PyMem_DEL(rfd2obj);
+ PyMem_DEL(wfd2obj);
+ PyMem_DEL(efd2obj);
+#endif
return ret;
}