diff options
author | Berker Peksag <berker.peksag@gmail.com> | 2016-09-26 20:30:41 (GMT) |
---|---|---|
committer | Berker Peksag <berker.peksag@gmail.com> | 2016-09-26 20:30:41 (GMT) |
commit | e2197d131290b59deb1ad47904e700b642ceffeb (patch) | |
tree | 2535fbb0cb97036b4215c8c3e963695e68c03923 /Modules/selectmodule.c | |
parent | 1849d894d56bba5e392766333657b0abe133da59 (diff) | |
download | cpython-e2197d131290b59deb1ad47904e700b642ceffeb.zip cpython-e2197d131290b59deb1ad47904e700b642ceffeb.tar.gz cpython-e2197d131290b59deb1ad47904e700b642ceffeb.tar.bz2 |
Issue #20100: Simplify newPyEpoll_Object()
EPOLL_CLOEXEC is the only value that can be passed
to epoll_create1() and we are passing EPOLL_CLOEXEC
unconditionally since Python 3.4.
Diffstat (limited to 'Modules/selectmodule.c')
-rw-r--r-- | Modules/selectmodule.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c index 47da493..79cf199 100644 --- a/Modules/selectmodule.c +++ b/Modules/selectmodule.c @@ -1252,7 +1252,7 @@ pyepoll_internal_close(pyEpoll_Object *self) } static PyObject * -newPyEpoll_Object(PyTypeObject *type, int sizehint, int flags, SOCKET fd) +newPyEpoll_Object(PyTypeObject *type, int sizehint, SOCKET fd) { pyEpoll_Object *self; @@ -1264,12 +1264,10 @@ newPyEpoll_Object(PyTypeObject *type, int sizehint, int flags, SOCKET fd) if (fd == -1) { Py_BEGIN_ALLOW_THREADS #ifdef HAVE_EPOLL_CREATE1 - flags |= EPOLL_CLOEXEC; - if (flags) - self->epfd = epoll_create1(flags); - else -#endif + self->epfd = epoll_create1(EPOLL_CLOEXEC); +#else self->epfd = epoll_create(sizehint); +#endif Py_END_ALLOW_THREADS } else { @@ -1305,8 +1303,12 @@ pyepoll_new(PyTypeObject *type, PyObject *args, PyObject *kwds) PyErr_SetString(PyExc_ValueError, "negative sizehint"); return NULL; } + if (flags && flags != EPOLL_CLOEXEC) { + PyErr_SetString(PyExc_OSError, "invalid flags"); + return NULL; + } - return newPyEpoll_Object(type, sizehint, flags, -1); + return newPyEpoll_Object(type, sizehint, -1); } @@ -1364,7 +1366,7 @@ pyepoll_fromfd(PyObject *cls, PyObject *args) if (!PyArg_ParseTuple(args, "i:fromfd", &fd)) return NULL; - return newPyEpoll_Object((PyTypeObject*)cls, FD_SETSIZE - 1, 0, fd); + return newPyEpoll_Object((PyTypeObject*)cls, FD_SETSIZE - 1, fd); } PyDoc_STRVAR(pyepoll_fromfd_doc, |