]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
fix for old kernels which don't have epoll_create1
authorBenjamin Peterson <benjamin@python.org>
Tue, 27 Dec 2011 21:36:32 +0000 (15:36 -0600)
committerBenjamin Peterson <benjamin@python.org>
Tue, 27 Dec 2011 21:36:32 +0000 (15:36 -0600)
Modules/selectmodule.c
configure
configure.in
pyconfig.h.in

index 6e3e6cbf1d5e4916a172319caa8caac508ba7dd9..a8413fede5cf31b0cea39cc9f619cf3ff16810e3 100644 (file)
@@ -1087,7 +1087,7 @@ pyepoll_internal_close(pyEpoll_Object *self)
 }
 
 static PyObject *
-newPyEpoll_Object(PyTypeObject *type, int flags, SOCKET fd)
+newPyEpoll_Object(PyTypeObject *type, int sizehint, int flags, SOCKET fd)
 {
     pyEpoll_Object *self;
 
@@ -1098,7 +1098,11 @@ newPyEpoll_Object(PyTypeObject *type, int flags, SOCKET fd)
 
     if (fd == -1) {
         Py_BEGIN_ALLOW_THREADS
+#ifdef HAVE_EPOLL_CREATE1
         self->epfd = epoll_create1(flags);
+#else
+        self->epfd = epoll_create(sizehint);
+#endif
         Py_END_ALLOW_THREADS
     }
     else {
@@ -1127,7 +1131,7 @@ pyepoll_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
         return NULL;
     }
 
-    return newPyEpoll_Object(type, flags, -1);
+    return newPyEpoll_Object(type, sizehint, flags, -1);
 }
 
 
@@ -1185,7 +1189,7 @@ pyepoll_fromfd(PyObject *cls, PyObject *args)
     if (!PyArg_ParseTuple(args, "i:fromfd", &fd))
         return NULL;
 
-    return newPyEpoll_Object((PyTypeObject*)cls, 0, fd);
+    return newPyEpoll_Object((PyTypeObject*)cls, FD_SETSIZE - 1, 0, fd);
 }
 
 PyDoc_STRVAR(pyepoll_fromfd_doc,
@@ -2213,7 +2217,9 @@ PyInit_select(void)
     PyModule_AddIntConstant(m, "EPOLLWRBAND", EPOLLWRBAND);
     PyModule_AddIntConstant(m, "EPOLLMSG", EPOLLMSG);
 
+#ifdef EPOLL_CLOEXEC
     PyModule_AddIntConstant(m, "EPOLL_CLOEXEC", EPOLL_CLOEXEC);
+#endif
 #endif /* HAVE_EPOLL */
 
 #ifdef HAVE_KQUEUE
index 455e62a87f3cbc909924472d0435e7ec5a011aaf..7cd7e91873234b6d8d6188ed5c46c2a61dcc2828 100755 (executable)
--- a/configure
+++ b/configure
@@ -9604,6 +9604,31 @@ else
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
 
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for epoll_create1" >&5
+$as_echo_n "checking for epoll_create1... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <sys/epoll.h>
+int
+main ()
+{
+void *x=epoll_create1
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+$as_echo "#define HAVE_EPOLL_CREATE1 1" >>confdefs.h
+
+   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for kqueue" >&5
@@ -14564,8 +14589,8 @@ esac
 
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 # Files that config.status was made for.
-config_files="`echo $ac_config_files`"
-config_headers="`echo $ac_config_headers`"
+config_files="$ac_config_files"
+config_headers="$ac_config_headers"
 
 _ACEOF
 
index 95fb8c5dddc9061640770762dddc7eb26430ebe3..b7eccb713616b06f3b3cad4bf27e9e30ac857375 100644 (file)
@@ -2628,6 +2628,12 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/epoll.h>]], [[void *x=epoll_c
    AC_MSG_RESULT(yes)],
   [AC_MSG_RESULT(no)
 ])
+AC_MSG_CHECKING(for epoll_create1)
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/epoll.h>]], [[void *x=epoll_create1]])],
+  [AC_DEFINE(HAVE_EPOLL_CREATE1, 1, Define if you have the 'epoll_create1' function.)
+   AC_MSG_RESULT(yes)],
+  [AC_MSG_RESULT(no)
+])
 AC_MSG_CHECKING(for kqueue)
 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 #include <sys/types.h>
index 6b497217d6c6a0de214315c53b117e7200b4c271..accc8938b06a2c09cabe6eca2c3432e7d5959891 100644 (file)
 /* Define if you have the 'epoll' functions. */
 #undef HAVE_EPOLL
 
+/* Define if you have the 'epoll_create1' function. */
+#undef HAVE_EPOLL_CREATE1
+
 /* Define to 1 if you have the `erf' function. */
 #undef HAVE_ERF