ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libev/ev_linuxaio.c
(Generate patch)

Comparing libev/ev_linuxaio.c (file contents):
Revision 1.32 by root, Tue Jun 25 18:07:44 2019 UTC vs.
Revision 1.34 by root, Wed Jun 26 00:01:46 2019 UTC

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)
508 /* it's easiest to handle this mess in another iteration */ 511 /* it's easiest to handle this mess in another iteration */
509 return; 512 return;
510 } 513 }
511 else if (errno == EBADF) 514 else if (errno == EBADF)
512 { 515 {
516 assert (("libev: event loop rejected bad fd", errno != EBADF));
513 fd_kill (EV_A_ linuxaio_submits [submitted]->aio_fildes); 517 fd_kill (EV_A_ linuxaio_submits [submitted]->aio_fildes);
514 518
515 res = 1; /* skip this iocb */ 519 res = 1; /* skip this iocb */
516 } 520 }
517 else 521 else
570void 574void
571linuxaio_destroy (EV_P) 575linuxaio_destroy (EV_P)
572{ 576{
573 epoll_destroy (EV_A); 577 epoll_destroy (EV_A);
574 linuxaio_free_iocbp (EV_A); 578 linuxaio_free_iocbp (EV_A);
575 evsys_io_destroy (linuxaio_ctx); 579 evsys_io_destroy (linuxaio_ctx); /* fails in child, aio context is destroyed */
576} 580}
577 581
578inline_size 582inline_size
579void 583void
580linuxaio_fork (EV_P) 584linuxaio_fork (EV_P)
586 linuxaio_iteration = 0; /* we start over in the child */ 590 linuxaio_iteration = 0; /* we start over in the child */
587 591
588 while (linuxaio_io_setup (EV_A) < 0) 592 while (linuxaio_io_setup (EV_A) < 0)
589 ev_syserr ("(libev) linuxaio io_setup"); 593 ev_syserr ("(libev) linuxaio io_setup");
590 594
595 /* forking epoll should also effectively unregister all fds from the backend */
591 epoll_fork (EV_A); 596 epoll_fork (EV_A);
592 597
593 ev_io_stop (EV_A_ &linuxaio_epoll_w); 598 ev_io_stop (EV_A_ &linuxaio_epoll_w);
594 ev_io_set (EV_A_ &linuxaio_epoll_w, backend_fd, EV_READ); 599 ev_io_set (EV_A_ &linuxaio_epoll_w, backend_fd, EV_READ);
595 ev_io_start (EV_A_ &linuxaio_epoll_w); 600 ev_io_start (EV_A_ &linuxaio_epoll_w);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines