… | |
… | |
243 | /* we do it manually because the optimisations on epoll_modify won't do us any good */ |
243 | /* we do it manually because the optimisations on epoll_modify won't do us any good */ |
244 | epoll_ctl (backend_fd, EPOLL_CTL_DEL, fd, 0); |
244 | epoll_ctl (backend_fd, EPOLL_CTL_DEL, fd, 0); |
245 | anfds [fd].emask = 0; |
245 | anfds [fd].emask = 0; |
246 | iocb->io.aio_reqprio = 0; |
246 | iocb->io.aio_reqprio = 0; |
247 | } |
247 | } |
248 | |
|
|
249 | if (ecb_expect_false (iocb->io.aio_buf)) |
248 | else if (ecb_expect_false (iocb->io.aio_buf)) |
250 | { |
249 | { |
251 | /* iocb active, so cancel it first before resubmit */ |
250 | /* iocb active, so cancel it first before resubmit */ |
252 | for (;;) |
251 | for (;;) |
253 | { |
252 | { |
254 | /* on all relevant kernels, io_cancel fails with EINPROGRESS on "success" */ |
253 | /* on all relevant kernels, io_cancel fails with EINPROGRESS on "success" */ |
… | |
… | |
257 | |
256 | |
258 | if (ecb_expect_true (errno == EINPROGRESS)) |
257 | if (ecb_expect_true (errno == EINPROGRESS)) |
259 | break; |
258 | break; |
260 | |
259 | |
261 | /* the EINPROGRESS test is for nicer error message. clumsy. */ |
260 | /* the EINPROGRESS test is for nicer error message. clumsy. */ |
|
|
261 | if (errno != EINTR) |
|
|
262 | { |
262 | assert (("libev: linuxaio unexpected io_cancel failed", errno != EINPROGRESS && errno != EINTR)); |
263 | assert (("libev: linuxaio unexpected io_cancel failed", errno != EINTR && errno != EINPROGRESS)); |
|
|
264 | break; |
|
|
265 | } |
263 | } |
266 | } |
264 | } |
267 | } |
265 | |
268 | |
266 | iocb->io.aio_buf = |
269 | iocb->io.aio_buf = |
267 | (nev & EV_READ ? POLLIN : 0) |
270 | (nev & EV_READ ? POLLIN : 0) |
… | |
… | |
584 | |
587 | |
585 | ecb_cold |
588 | ecb_cold |
586 | static void |
589 | static void |
587 | linuxaio_fork (EV_P) |
590 | linuxaio_fork (EV_P) |
588 | { |
591 | { |
589 | /* this frees all iocbs, which is very heavy-handed */ |
|
|
590 | linuxaio_destroy (EV_A); |
|
|
591 | linuxaio_submitcnt = 0; /* all pointers were invalidated */ |
592 | linuxaio_submitcnt = 0; /* all pointers were invalidated */ |
|
|
593 | linuxaio_free_iocp (EV_A); /* this frees all iocbs, which is very heavy-handed */ |
|
|
594 | evsys_io_destroy (linuxaio_ctx); /* fails in child, aio context is destroyed */ |
592 | |
595 | |
593 | linuxaio_iteration = 0; /* we start over in the child */ |
596 | linuxaio_iteration = 0; /* we start over in the child */ |
594 | |
597 | |
595 | while (linuxaio_io_setup (EV_A) < 0) |
598 | while (linuxaio_io_setup (EV_A) < 0) |
596 | ev_syserr ("(libev) linuxaio io_setup"); |
599 | ev_syserr ("(libev) linuxaio io_setup"); |