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.13 by root, Sun Jun 23 23:38:38 2019 UTC vs.
Revision 1.15 by root, Mon Jun 24 00:04:26 2019 UTC

336 break; 336 break;
337 } 337 }
338#if EPOLL_FALLBACK 338#if EPOLL_FALLBACK
339 else if (errno == EINVAL) 339 else if (errno == EINVAL)
340 { 340 {
341 /* This hapΓΌpens for unsupported fds, officially, but in my testing, 341 /* This happens for unsupported fds, officially, but in my testing,
342 * also randomly happens for supported fds. We fall back to good old 342 * also randomly happens for supported fds. We fall back to good old
343 * poll() here, under the assumption that this is a very rare case. 343 * poll() here, under the assumption that this is a very rare case.
344 * See https://lore.kernel.org/patchwork/patch/1047453/ for evidence
345 * that the problem is known, but ignored.
344 */ 346 */
345 struct iocb *iocb = linuxaio_submits [submitted]; 347 struct iocb *iocb = linuxaio_submits [submitted];
346 res = 1; /* skip this iocb */ 348 res = 1; /* skip this iocb */
347 349
348 linuxaio_rearm_epoll (EV_A_ iocb, EPOLL_CTL_ADD); 350 linuxaio_rearm_epoll (EV_A_ iocb, EPOLL_CTL_ADD);
404int 406int
405linuxaio_init (EV_P_ int flags) 407linuxaio_init (EV_P_ int flags)
406{ 408{
407 /* would be great to have a nice test for IOCB_CMD_POLL instead */ 409 /* would be great to have a nice test for IOCB_CMD_POLL instead */
408 /* also: test some semi-common fd types, such as files and ttys in recommended_backends */ 410 /* also: test some semi-common fd types, such as files and ttys in recommended_backends */
409 if (ev_linux_version () < 0x041200) /* 4.18 introduced IOCB_CMD_POLL */ 411#if EPOLL_FALLBACK
412 /* 4.19 made epoll work */
413 if (ev_linux_version () < 0x041300)
410 return 0; 414 return 0;
415#else
416 /* 4.18 introduced IOCB_CMD_POLL */
417 if (ev_linux_version () < 0x041200)
418 return 0;
419#endif
411 420
412 linuxaio_ctx = 0; 421 linuxaio_ctx = 0;
413 if (ev_io_setup (EV_LINUXAIO_DEPTH, &linuxaio_ctx) < 0) 422 if (ev_io_setup (EV_LINUXAIO_DEPTH, &linuxaio_ctx) < 0)
414 return 0; 423 return 0;
415 424
421 return 0; 430 return 0;
422 } 431 }
423 432
424 ev_io_init (EV_A_ &linuxaio_epoll_w, linuxaio_epoll_cb, backend_fd, EV_READ); 433 ev_io_init (EV_A_ &linuxaio_epoll_w, linuxaio_epoll_cb, backend_fd, EV_READ);
425 ev_io_start (EV_A_ &linuxaio_epoll_w); 434 ev_io_start (EV_A_ &linuxaio_epoll_w);
435 ev_unref (EV_A); /* watcher should not keep loop alive */
426#endif 436#endif
427 437
428 backend_modify = linuxaio_modify; 438 backend_modify = linuxaio_modify;
429 backend_poll = linuxaio_poll; 439 backend_poll = linuxaio_poll;
430 440
466 ev_syserr ("(libev) linuxaio epoll_create"); 476 ev_syserr ("(libev) linuxaio epoll_create");
467 477
468 ev_io_stop (EV_A_ &linuxaio_epoll_w); 478 ev_io_stop (EV_A_ &linuxaio_epoll_w);
469 ev_io_init (EV_A_ &linuxaio_epoll_w, linuxaio_epoll_cb, backend_fd, EV_READ); 479 ev_io_init (EV_A_ &linuxaio_epoll_w, linuxaio_epoll_cb, backend_fd, EV_READ);
470 ev_io_start (EV_A_ &linuxaio_epoll_w); 480 ev_io_start (EV_A_ &linuxaio_epoll_w);
471 ev_unref (EV_A); /* watcher should not keep loop alive */
472#endif 481#endif
473 482
474 fd_rearm_all (EV_A); 483 fd_rearm_all (EV_A);
475} 484}
476 485

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines