@@ -1087,28 +1087,18 @@ pyepoll_internal_close(pyEpoll_Object *self)
10871087}
10881088
10891089static PyObject *
1090- newPyEpoll_Object (PyTypeObject * type , int sizehint , SOCKET fd )
1090+ newPyEpoll_Object (PyTypeObject * type , int flags , SOCKET fd )
10911091{
10921092 pyEpoll_Object * self ;
10931093
1094- if (sizehint == -1 ) {
1095- sizehint = FD_SETSIZE - 1 ;
1096- }
1097- else if (sizehint < 1 ) {
1098- PyErr_Format (PyExc_ValueError ,
1099- "sizehint must be greater zero, got %d" ,
1100- sizehint );
1101- return NULL ;
1102- }
1103-
11041094 assert (type != NULL && type -> tp_alloc != NULL );
11051095 self = (pyEpoll_Object * ) type -> tp_alloc (type , 0 );
11061096 if (self == NULL )
11071097 return NULL ;
11081098
11091099 if (fd == -1 ) {
11101100 Py_BEGIN_ALLOW_THREADS
1111- self -> epfd = epoll_create ( sizehint );
1101+ self -> epfd = epoll_create1 ( flags );
11121102 Py_END_ALLOW_THREADS
11131103 }
11141104 else {
@@ -1126,14 +1116,18 @@ newPyEpoll_Object(PyTypeObject *type, int sizehint, SOCKET fd)
11261116static PyObject *
11271117pyepoll_new (PyTypeObject * type , PyObject * args , PyObject * kwds )
11281118{
1129- int sizehint = -1 ;
1130- static char * kwlist [] = {"sizehint" , NULL };
1119+ int flags = 0 , sizehint = 0 ;
1120+ static char * kwlist [] = {"sizehint" , "flags" , NULL };
11311121
1132- if (!PyArg_ParseTupleAndKeywords (args , kwds , "|i:epoll" , kwlist ,
1133- & sizehint ))
1122+ if (!PyArg_ParseTupleAndKeywords (args , kwds , "|ii:epoll" , kwlist ,
1123+ & sizehint , & flags ))
1124+ return NULL ;
1125+ if (sizehint < 0 ) {
1126+ PyErr_SetString (PyExc_ValueError , "negative sizehint" );
11341127 return NULL ;
1128+ }
11351129
1136- return newPyEpoll_Object (type , sizehint , -1 );
1130+ return newPyEpoll_Object (type , flags , -1 );
11371131}
11381132
11391133
@@ -1191,7 +1185,7 @@ pyepoll_fromfd(PyObject *cls, PyObject *args)
11911185 if (!PyArg_ParseTuple (args , "i:fromfd" , & fd ))
11921186 return NULL ;
11931187
1194- return newPyEpoll_Object ((PyTypeObject * )cls , -1 , fd );
1188+ return newPyEpoll_Object ((PyTypeObject * )cls , 0 , fd );
11951189}
11961190
11971191PyDoc_STRVAR (pyepoll_fromfd_doc ,
@@ -1420,7 +1414,7 @@ static PyGetSetDef pyepoll_getsetlist[] = {
14201414};
14211415
14221416PyDoc_STRVAR (pyepoll_doc ,
1423- "select.epoll([ sizehint=-1] )\n\
1417+ "select.epoll(sizehint=-1, flags=0 )\n\
14241418\n\
14251419Returns an epolling object\n\
14261420\n\
@@ -2218,6 +2212,8 @@ PyInit_select(void)
22182212 PyModule_AddIntConstant (m , "EPOLLWRNORM" , EPOLLWRNORM );
22192213 PyModule_AddIntConstant (m , "EPOLLWRBAND" , EPOLLWRBAND );
22202214 PyModule_AddIntConstant (m , "EPOLLMSG" , EPOLLMSG );
2215+
2216+ PyModule_AddIntConstant (m , "EPOLL_CLOEXEC" , EPOLL_CLOEXEC );
22212217#endif /* HAVE_EPOLL */
22222218
22232219#ifdef HAVE_KQUEUE
0 commit comments