EV
view release on metacpan or search on metacpan
libev/ev_linuxaio.c view on Meta::CPAN
linuxaio_ctx = 0;
backend = EVBACKEND_EPOLL;
backend_modify = epoll_modify;
backend_poll = epoll_poll;
}
timeout = EV_TS_CONST (0.);
/* it's easiest to handle this mess in another iteration */
return;
}
else if (errno == EBADF)
{
assert (("libev: event loop rejected bad fd", errno != EBADF));
fd_kill (EV_A_ linuxaio_submits [submitted]->aio_fildes);
res = 1; /* skip this iocb */
}
else if (errno == EINTR) /* not seen in reality, not documented */
res = 0; /* silently ignore and retry */
else
{
ev_syserr ("(libev) linuxaio io_submit");
res = 0;
}
submitted += res;
}
linuxaio_submitcnt = 0;
/* second phase: fetch and parse events */
linuxaio_get_events (EV_A_ timeout);
}
inline_size
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 */
/* 4.18 introduced IOCB_CMD_POLL, 4.19 made epoll work, and we need that */
if (ev_linux_version () < 0x041300)
return 0;
if (!epoll_init (EV_A_ 0))
return 0;
linuxaio_iteration = 0;
if (linuxaio_io_setup (EV_A) < 0)
{
epoll_destroy (EV_A);
return 0;
}
ev_io_init (&linuxaio_epoll_w, linuxaio_epoll_cb, backend_fd, EV_READ);
ev_set_priority (&linuxaio_epoll_w, EV_MAXPRI);
ev_io_start (EV_A_ &linuxaio_epoll_w);
ev_unref (EV_A); /* watcher should not keep loop alive */
backend_modify = linuxaio_modify;
backend_poll = linuxaio_poll;
linuxaio_iocbpmax = 0;
linuxaio_iocbps = 0;
linuxaio_submits = 0;
linuxaio_submitmax = 0;
linuxaio_submitcnt = 0;
return EVBACKEND_LINUXAIO;
}
inline_size
void
linuxaio_destroy (EV_P)
{
epoll_destroy (EV_A);
linuxaio_free_iocbp (EV_A);
evsys_io_destroy (linuxaio_ctx); /* fails in child, aio context is destroyed */
}
ecb_cold
static void
linuxaio_fork (EV_P)
{
linuxaio_submitcnt = 0; /* all pointers were invalidated */
linuxaio_free_iocbp (EV_A); /* this frees all iocbs, which is very heavy-handed */
evsys_io_destroy (linuxaio_ctx); /* fails in child, aio context is destroyed */
linuxaio_iteration = 0; /* we start over in the child */
while (linuxaio_io_setup (EV_A) < 0)
ev_syserr ("(libev) linuxaio io_setup");
/* forking epoll should also effectively unregister all fds from the backend */
epoll_fork (EV_A);
/* epoll_fork already did this. hopefully */
/*fd_rearm_all (EV_A);*/
ev_io_stop (EV_A_ &linuxaio_epoll_w);
ev_io_set (EV_A_ &linuxaio_epoll_w, backend_fd, EV_READ);
ev_io_start (EV_A_ &linuxaio_epoll_w);
}
( run in 1.064 second using v1.01-cache-2.11-cpan-39bf76dae61 )