… | |
… | |
289 | ANIOCBP iocb = linuxaio_iocbps [fd]; |
289 | ANIOCBP iocb = linuxaio_iocbps [fd]; |
290 | |
290 | |
291 | if (iocb->io.aio_reqprio < 0) |
291 | if (iocb->io.aio_reqprio < 0) |
292 | { |
292 | { |
293 | /* we handed this fd over to epoll, so undo this first */ |
293 | /* we handed this fd over to epoll, so undo this first */ |
294 | /* we do it manually because the optimisations on epoll_modfy won't do us any good */ |
294 | /* we do it manually because the optimisations on epoll_modify won't do us any good */ |
295 | epoll_ctl (backend_fd, EPOLL_CTL_DEL, fd, 0); |
295 | epoll_ctl (backend_fd, EPOLL_CTL_DEL, fd, 0); |
296 | anfds [fd].emask = 0; |
296 | anfds [fd].emask = 0; |
297 | iocb->io.aio_reqprio = 0; |
297 | iocb->io.aio_reqprio = 0; |
298 | } |
298 | } |
299 | |
299 | |
300 | if (iocb->io.aio_buf) |
300 | if (iocb->io.aio_buf) |
301 | /* io_cancel always returns some error on relevant kernels, but works */ |
301 | { |
302 | evsys_io_cancel (linuxaio_ctx, &iocb->io, (struct io_event *)0); |
302 | evsys_io_cancel (linuxaio_ctx, &iocb->io, (struct io_event *)0); |
|
|
303 | /* on relevant kernels, io_cancel fails with EINPROGRES if everything is fine */ |
|
|
304 | assert (("libev: linuxaio unexpected io_cancel failed", errno == EINPROGRESS)); |
|
|
305 | } |
303 | |
306 | |
304 | if (nev) |
307 | if (nev) |
305 | { |
308 | { |
306 | iocb->io.aio_buf = |
309 | iocb->io.aio_buf = |
307 | (nev & EV_READ ? POLLIN : 0) |
310 | (nev & EV_READ ? POLLIN : 0) |
… | |
… | |
319 | linuxaio_epoll_cb (EV_P_ struct ev_io *w, int revents) |
322 | linuxaio_epoll_cb (EV_P_ struct ev_io *w, int revents) |
320 | { |
323 | { |
321 | epoll_poll (EV_A_ 0); |
324 | epoll_poll (EV_A_ 0); |
322 | } |
325 | } |
323 | |
326 | |
324 | static void |
327 | inline_speed |
|
|
328 | void |
325 | linuxaio_fd_rearm (EV_P_ int fd) |
329 | linuxaio_fd_rearm (EV_P_ int fd) |
326 | { |
330 | { |
327 | anfds [fd].events = 0; |
331 | anfds [fd].events = 0; |
328 | linuxaio_iocbps [fd]->io.aio_buf = 0; |
332 | linuxaio_iocbps [fd]->io.aio_buf = 0; |
329 | fd_change (EV_A_ fd, EV_ANFD_REIFY); |
333 | fd_change (EV_A_ fd, EV_ANFD_REIFY); |
… | |
… | |
345 | fd, |
349 | fd, |
346 | (res & (POLLOUT | POLLERR | POLLHUP) ? EV_WRITE : 0) |
350 | (res & (POLLOUT | POLLERR | POLLHUP) ? EV_WRITE : 0) |
347 | | (res & (POLLIN | POLLERR | POLLHUP) ? EV_READ : 0) |
351 | | (res & (POLLIN | POLLERR | POLLHUP) ? EV_READ : 0) |
348 | ); |
352 | ); |
349 | |
353 | |
350 | /* linux aio is oneshot: rearm fd. TODO: this does more work than needed */ |
354 | /* linux aio is oneshot: rearm fd. TODO: this does more work than strictly needed */ |
351 | linuxaio_fd_rearm (EV_A_ fd); |
355 | linuxaio_fd_rearm (EV_A_ fd); |
352 | |
356 | |
353 | --nr; |
357 | --nr; |
354 | ++ev; |
358 | ++ev; |
355 | } |
359 | } |
… | |
… | |
508 | /* it's easiest to handle this mess in another iteration */ |
512 | /* it's easiest to handle this mess in another iteration */ |
509 | return; |
513 | return; |
510 | } |
514 | } |
511 | else if (errno == EBADF) |
515 | else if (errno == EBADF) |
512 | { |
516 | { |
|
|
517 | assert (("libev: event loop rejected bad fd", errno != EBADF)); |
513 | fd_kill (EV_A_ linuxaio_submits [submitted]->aio_fildes); |
518 | fd_kill (EV_A_ linuxaio_submits [submitted]->aio_fildes); |
514 | |
519 | |
515 | res = 1; /* skip this iocb */ |
520 | res = 1; /* skip this iocb */ |
516 | } |
521 | } |
517 | else |
522 | else |