Browse Source

*** empty log message ***

master
Marc Alexander Lehmann 1 year ago
parent
commit
98421aae10
3 changed files with 36 additions and 5 deletions
  1. +20
    -0
      ev.c
  2. +14
    -4
      ev_linuxaio.c
  3. +2
    -1
      libev.m4

+ 20
- 0
ev.c View File

@ -117,6 +117,15 @@
# define EV_USE_EPOLL 0
# endif
# if HAVE_LINUX_AIO_ABI_H
# ifndef EV_USE_LINUXAIO
# define EV_USE_LINUXAIO EV_FEATURE_BACKENDS
# endif
# else
# undef EV_USE_LINUXAIO
# define EV_USE_LINUXAIO 0
# endif
# if HAVE_KQUEUE && HAVE_SYS_EVENT_H
# ifndef EV_USE_KQUEUE
# define EV_USE_KQUEUE EV_FEATURE_BACKENDS
@ -429,6 +438,14 @@
# endif
#endif
#if EV_USE_LINUXAIO
# include <sys/syscall.h>
# if !SYS_io_getevents
# undef EV_USE_LINUXAIO
# define EV_USE_LINUXAIO 0
# endif
#endif
#if EV_USE_INOTIFY
# include <sys/statfs.h>
# include <sys/inotify.h>
@ -2787,6 +2804,9 @@ ev_recommended_backends (void) EV_NOEXCEPT
flags &= ~EVBACKEND_POLL; /* poll return value is unusable (http://forums.freebsd.org/archive/index.php/t-10270.html) */
#endif
/* TODO: linuxaio is very experimental */
flags &= ~EVBACKEND_LINUXAIO;
return flags;
}


+ 14
- 4
ev_linuxaio.c View File

@ -38,6 +38,7 @@
*/
#include <sys/time.h> /* actually linux/time.h, but we must assume they are compatible */
#include <poll.h>
#include <linux/aio_abi.h>
/* we try to fill 4kn pages exactly.
@ -123,6 +124,7 @@ linuxaio_array_needsize_iocbp (ANIOCBP *base, int count)
while (count--)
{
*base = (ANIOCBP)ev_malloc (sizeof (**base));
/* TODO: full zero initialize required? */
memset (*base, 0, sizeof (**base));
/* would be nice to initialize fd/data as well */
(*base)->io.aio_lio_opcode = IOCB_CMD_POLL;
@ -136,18 +138,19 @@ linuxaio_free_iocbp (EV_P)
while (linuxaio_iocbpmax--)
ev_free (linuxaio_iocbps [linuxaio_iocbpmax]);
/* next resize will completely reallocate the array */
linuxaio_iocbpmax = 0;
linuxaio_submitcnt = 0; /* all pointers invalidated */
}
static void
linuxaio_modify (EV_P_ int fd, int oev, int nev)
{
/* TODO: full zero initialize required? */
array_needsize (ANIOCBP, linuxaio_iocbps, linuxaio_iocbpmax, fd + 1, linuxaio_array_needsize_iocbp);
struct aniocb *iocb = linuxaio_iocbps [fd];
if (iocb->io.aio_buf)
ev_io_cancel (linuxaio_ctx, &iocb->io, (void *)0);
ev_io_cancel (linuxaio_ctx, &iocb->io, (struct io_event *)0);
if (nev)
{
@ -173,7 +176,7 @@ linuxaio_parse_events (EV_P_ struct io_event *ev, int nr)
int fd = ev->data;
int res = ev->res;
assert (("libev: iocb fd must be in-bounds", fd >= 0 && fd < anfdxmax));
assert (("libev: iocb fd must be in-bounds", fd >= 0 && fd < anfdmax));
/* linux aio is oneshot: rearm fd */
linuxaio_iocbps [fd]->io.aio_buf = 0;
@ -306,6 +309,7 @@ int
linuxaio_init (EV_P_ int flags)
{
/* would be great to have a nice test for IOCB_CMD_POLL instead */
/* also: test some semi-common fd types, such as files and ttys in recommended_backends */
if (ev_linux_version () < 0x041200) /* 4.18 introduced IOCB_CMD_POLL */
return 0;
@ -337,6 +341,12 @@ inline_size
void
linuxaio_fork (EV_P)
{
abort ();//D
/* TODO: verify and test */
linuxaio_destroy (EV_A);
while (ev_io_setup (EV_LINUXAIO_DEPTH, &linuxaio_ctx) < 0)
ev_syserr ("(libev) io_setup");
fd_rearm_all (EV_A);
}

+ 2
- 1
libev.m4 View File

@ -2,7 +2,8 @@ dnl this file is part of libev, do not make local modifications
dnl http://software.schmorp.de/pkg/libev
dnl libev support
AC_CHECK_HEADERS(sys/inotify.h sys/epoll.h sys/event.h port.h poll.h sys/select.h sys/eventfd.h sys/signalfd.h)
AC_CHECK_HEADERS(sys/inotify.h sys/epoll.h sys/event.h port.h poll.h)
AC_CHECK_HEADERS(sys/select.h sys/eventfd.h sys/signalfd.h linux/aio_abi.h)
AC_CHECK_FUNCS(inotify_init epoll_ctl kqueue port_create poll select eventfd signalfd)


Loading…
Cancel
Save