Commit 3f6af410 authored by Jason Madden's avatar Jason Madden

Support new backends in libev.

parent 5d2801a9
...@@ -43,6 +43,8 @@ ...@@ -43,6 +43,8 @@
#define EVBACKEND_KQUEUE ... #define EVBACKEND_KQUEUE ...
#define EVBACKEND_DEVPOLL ... #define EVBACKEND_DEVPOLL ...
#define EVBACKEND_PORT ... #define EVBACKEND_PORT ...
#define EVBACKEND_LINUXAIO ...
#define EVBACKEND_IOURING ...
/* #define EVBACKEND_IOCP ... */ /* #define EVBACKEND_IOCP ... */
#define EVBACKEND_ALL ... #define EVBACKEND_ALL ...
......
...@@ -103,11 +103,16 @@ READWRITE = libev.EV_READ | libev.EV_WRITE ...@@ -103,11 +103,16 @@ READWRITE = libev.EV_READ | libev.EV_WRITE
MINPRI = libev.EV_MINPRI MINPRI = libev.EV_MINPRI
MAXPRI = libev.EV_MAXPRI MAXPRI = libev.EV_MAXPRI
BACKEND_PORT = libev.EVBACKEND_PORT
BACKEND_KQUEUE = libev.EVBACKEND_KQUEUE
BACKEND_EPOLL = libev.EVBACKEND_EPOLL
BACKEND_POLL = libev.EVBACKEND_POLL
BACKEND_SELECT = libev.EVBACKEND_SELECT BACKEND_SELECT = libev.EVBACKEND_SELECT
BACKEND_POLL = libev.EVBACKEND_POLL
BACKEND_EPOLL = libev.EVBACKEND_EPOLL
BACKEND_KQUEUE = libev.EVBACKEND_KQUEUE
BACKEND_DEVPOLL = libev.EVBACKEND_DEVPOLL
BACKEND_PORT = libev.EVBACKEND_PORT
BACKEND_LINUXAIO = libev.EVBACKEND_LINUXAIO
BACKEND_IOURING = libev.EVBACKEND_IOURING
FORKCHECK = libev.EVFLAG_FORKCHECK FORKCHECK = libev.EVFLAG_FORKCHECK
NOINOTIFY = libev.EVFLAG_NOINOTIFY NOINOTIFY = libev.EVFLAG_NOINOTIFY
SIGNALFD = libev.EVFLAG_SIGNALFD SIGNALFD = libev.EVFLAG_SIGNALFD
...@@ -133,17 +138,24 @@ def get_header_version(): ...@@ -133,17 +138,24 @@ def get_header_version():
return 'libev-%d.%02d' % (libev.EV_VERSION_MAJOR, libev.EV_VERSION_MINOR) return 'libev-%d.%02d' % (libev.EV_VERSION_MAJOR, libev.EV_VERSION_MINOR)
# This list backends in the order they are actually tried by libev # This list backends in the order they are actually tried by libev,
_flags = [(libev.EVBACKEND_PORT, 'port'), # as defined in loop_init. The names must be lower case.
(libev.EVBACKEND_KQUEUE, 'kqueue'), _flags = [
(libev.EVBACKEND_EPOLL, 'epoll'), # IOCP
(libev.EVBACKEND_POLL, 'poll'), (libev.EVBACKEND_PORT, 'port'),
(libev.EVBACKEND_SELECT, 'select'), (libev.EVBACKEND_KQUEUE, 'kqueue'),
(libev.EVFLAG_NOENV, 'noenv'), (libev.EVBACKEND_IOURING, 'linux_iouring'),
(libev.EVFLAG_FORKCHECK, 'forkcheck'), (libev.EVBACKEND_LINUXAIO, "linux_aio"),
(libev.EVFLAG_NOINOTIFY, 'noinotify'), (libev.EVBACKEND_EPOLL, 'epoll'),
(libev.EVFLAG_SIGNALFD, 'signalfd'), (libev.EVBACKEND_POLL, 'poll'),
(libev.EVFLAG_NOSIGMASK, 'nosigmask')] (libev.EVBACKEND_SELECT, 'select'),
(libev.EVFLAG_NOENV, 'noenv'),
(libev.EVFLAG_FORKCHECK, 'forkcheck'),
(libev.EVFLAG_NOINOTIFY, 'noinotify'),
(libev.EVFLAG_SIGNALFD, 'signalfd'),
(libev.EVFLAG_NOSIGMASK, 'nosigmask')
]
_flags_str2int = dict((string, flag) for (flag, string) in _flags) _flags_str2int = dict((string, flag) for (flag, string) in _flags)
......
...@@ -110,15 +110,23 @@ def get_version(): ...@@ -110,15 +110,23 @@ def get_version():
def get_header_version(): def get_header_version():
return 'libev-%d.%02d' % (libev.EV_VERSION_MAJOR, libev.EV_VERSION_MINOR) return 'libev-%d.%02d' % (libev.EV_VERSION_MAJOR, libev.EV_VERSION_MINOR)
_flags = [(libev.EVBACKEND_PORT, 'port'), # This list backends in the order they are actually tried by libev,
(libev.EVBACKEND_KQUEUE, 'kqueue'), # as defined in loop_init. The names must be lower case.
(libev.EVBACKEND_EPOLL, 'epoll'), _flags = [
(libev.EVBACKEND_POLL, 'poll'), # IOCP --- not supported/used.
(libev.EVBACKEND_SELECT, 'select'), (libev.EVBACKEND_PORT, 'port'),
(libev.EVFLAG_NOENV, 'noenv'), (libev.EVBACKEND_KQUEUE, 'kqueue'),
(libev.EVFLAG_FORKCHECK, 'forkcheck'), (libev.EVBACKEND_IOURING, 'linux_iouring'),
(libev.EVFLAG_SIGNALFD, 'signalfd'), (libev.EVBACKEND_LINUXAIO, "linux_aio"),
(libev.EVFLAG_NOSIGMASK, 'nosigmask')] (libev.EVBACKEND_EPOLL, 'epoll'),
(libev.EVBACKEND_POLL, 'poll'),
(libev.EVBACKEND_SELECT, 'select'),
(libev.EVFLAG_NOENV, 'noenv'),
(libev.EVFLAG_FORKCHECK, 'forkcheck'),
(libev.EVFLAG_SIGNALFD, 'signalfd'),
(libev.EVFLAG_NOSIGMASK, 'nosigmask')
]
_flags_str2int = dict((string, flag) for (flag, string) in _flags) _flags_str2int = dict((string, flag) for (flag, string) in _flags)
......
...@@ -74,6 +74,8 @@ cdef extern from "libev.h" nogil: ...@@ -74,6 +74,8 @@ cdef extern from "libev.h" nogil:
int EVBACKEND_DEVPOLL int EVBACKEND_DEVPOLL
int EVBACKEND_PORT int EVBACKEND_PORT
int EVBACKEND_IOCP int EVBACKEND_IOCP
int EVBACKEND_IOURING
int EVBACKEND_LINUXAIO
int EVBACKEND_ALL int EVBACKEND_ALL
int EVBACKEND_MASK int EVBACKEND_MASK
......
...@@ -22,6 +22,13 @@ class Test(unittest.TestCase): ...@@ -22,6 +22,13 @@ class Test(unittest.TestCase):
assertRaisesRegex = getattr(unittest.TestCase, 'assertRaisesRegex', assertRaisesRegex = getattr(unittest.TestCase, 'assertRaisesRegex',
getattr(unittest.TestCase, 'assertRaisesRegexp')) getattr(unittest.TestCase, 'assertRaisesRegexp'))
BACKENDS_THAT_SUCCEED_WHEN_FD_CLOSED = (
'kqueue',
'epoll',
'linux_aio',
'linux_iouring',
)
def _check_backend(self, backend): def _check_backend(self, backend):
hub = Hub(backend, default=False) hub = Hub(backend, default=False)
try: try:
...@@ -33,9 +40,10 @@ class Test(unittest.TestCase): ...@@ -33,9 +40,10 @@ class Test(unittest.TestCase):
raise unittest.SkipTest("backend %s lacks fileno" % (backend,)) raise unittest.SkipTest("backend %s lacks fileno" % (backend,))
os.close(fileno) os.close(fileno)
if backend not in ('kqueue', 'epoll'):
# That's actually all the libev backends that use a file descriptor, if backend in self.BACKENDS_THAT_SUCCEED_WHEN_FD_CLOSED:
# right? gevent.sleep(0.001)
else:
with self.assertRaisesRegex(SystemError, "(libev)"): with self.assertRaisesRegex(SystemError, "(libev)"):
gevent.sleep(0.001) gevent.sleep(0.001)
...@@ -52,6 +60,7 @@ class Test(unittest.TestCase): ...@@ -52,6 +60,7 @@ class Test(unittest.TestCase):
return test.__name__, test return test.__name__, test
count = backend = None count = backend = None
for count in range(2): for count in range(2):
for backend in core.supported_backends(): for backend in core.supported_backends():
name, func = _make_test(count, backend) name, func = _make_test(count, backend)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment