diff options
author | Benjamin Peterson <benjamin@python.org> | 2011-12-27 21:36:32 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2011-12-27 21:36:32 (GMT) |
commit | 95c16629d3549e7306d297ed09e26e58b151f720 (patch) | |
tree | b6d9d79119a31b9029a4bad9d82c27ea362886b3 /Modules/selectmodule.c | |
parent | a5f6f2aba34dcf8f2a7e899aff0d7c37218502e9 (diff) | |
download | cpython-95c16629d3549e7306d297ed09e26e58b151f720.zip cpython-95c16629d3549e7306d297ed09e26e58b151f720.tar.gz cpython-95c16629d3549e7306d297ed09e26e58b151f720.tar.bz2 |
fix for old kernels which don't have epoll_create1
Diffstat (limited to 'Modules/selectmodule.c')
-rw-r--r-- | Modules/selectmodule.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c index 6e3e6cb..a8413fe 100644 --- a/Modules/selectmodule.c +++ b/Modules/selectmodule.c @@ -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 |