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

Support new backends in libev.

parent 5d2801a9
......@@ -43,6 +43,8 @@
#define EVBACKEND_KQUEUE ...
#define EVBACKEND_DEVPOLL ...
#define EVBACKEND_PORT ...
#define EVBACKEND_LINUXAIO ...
#define EVBACKEND_IOURING ...
/* #define EVBACKEND_IOCP ... */
#define EVBACKEND_ALL ...
......
......@@ -103,11 +103,16 @@ READWRITE = libev.EV_READ | libev.EV_WRITE
MINPRI = libev.EV_MINPRI
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_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
NOINOTIFY = libev.EVFLAG_NOINOTIFY
SIGNALFD = libev.EVFLAG_SIGNALFD
......@@ -133,17 +138,24 @@ def get_header_version():
return 'libev-%d.%02d' % (libev.EV_VERSION_MAJOR, libev.EV_VERSION_MINOR)
# This list backends in the order they are actually tried by libev
_flags = [(libev.EVBACKEND_PORT, 'port'),
(libev.EVBACKEND_KQUEUE, 'kqueue'),
(libev.EVBACKEND_EPOLL, 'epoll'),
(libev.EVBACKEND_POLL, 'poll'),
(libev.EVBACKEND_SELECT, 'select'),
(libev.EVFLAG_NOENV, 'noenv'),
(libev.EVFLAG_FORKCHECK, 'forkcheck'),
(libev.EVFLAG_NOINOTIFY, 'noinotify'),
(libev.EVFLAG_SIGNALFD, 'signalfd'),
(libev.EVFLAG_NOSIGMASK, 'nosigmask')]
# This list backends in the order they are actually tried by libev,
# as defined in loop_init. The names must be lower case.
_flags = [
# IOCP
(libev.EVBACKEND_PORT, 'port'),
(libev.EVBACKEND_KQUEUE, 'kqueue'),
(libev.EVBACKEND_IOURING, 'linux_iouring'),
(libev.EVBACKEND_LINUXAIO, "linux_aio"),
(libev.EVBACKEND_EPOLL, 'epoll'),
(libev.EVBACKEND_POLL, 'poll'),
(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)
......
......@@ -110,15 +110,23 @@ def get_version():
def get_header_version():
return 'libev-%d.%02d' % (libev.EV_VERSION_MAJOR, libev.EV_VERSION_MINOR)
_flags = [(libev.EVBACKEND_PORT, 'port'),
(libev.EVBACKEND_KQUEUE, 'kqueue'),
(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')]
# This list backends in the order they are actually tried by libev,
# as defined in loop_init. The names must be lower case.
_flags = [
# IOCP --- not supported/used.
(libev.EVBACKEND_PORT, 'port'),
(libev.EVBACKEND_KQUEUE, 'kqueue'),
(libev.EVBACKEND_IOURING, 'linux_iouring'),
(libev.EVBACKEND_LINUXAIO, "linux_aio"),
(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)
......
......@@ -74,6 +74,8 @@ cdef extern from "libev.h" nogil:
int EVBACKEND_DEVPOLL
int EVBACKEND_PORT
int EVBACKEND_IOCP
int EVBACKEND_IOURING
int EVBACKEND_LINUXAIO
int EVBACKEND_ALL
int EVBACKEND_MASK
......
......@@ -22,6 +22,13 @@ class Test(unittest.TestCase):
assertRaisesRegex = getattr(unittest.TestCase, 'assertRaisesRegex',
getattr(unittest.TestCase, 'assertRaisesRegexp'))
BACKENDS_THAT_SUCCEED_WHEN_FD_CLOSED = (
'kqueue',
'epoll',
'linux_aio',
'linux_iouring',
)
def _check_backend(self, backend):
hub = Hub(backend, default=False)
try:
......@@ -33,9 +40,10 @@ class Test(unittest.TestCase):
raise unittest.SkipTest("backend %s lacks fileno" % (backend,))
os.close(fileno)
if backend not in ('kqueue', 'epoll'):
# That's actually all the libev backends that use a file descriptor,
# right?
if backend in self.BACKENDS_THAT_SUCCEED_WHEN_FD_CLOSED:
gevent.sleep(0.001)
else:
with self.assertRaisesRegex(SystemError, "(libev)"):
gevent.sleep(0.001)
......@@ -52,6 +60,7 @@ class Test(unittest.TestCase):
return test.__name__, test
count = backend = None
for count in range(2):
for backend in core.supported_backends():
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