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

Comparing libev/ev_iouring.c (file contents):
Revision 1.1 by root, Tue Jul 2 06:07:54 2019 UTC vs.
Revision 1.4 by root, Wed Aug 28 10:05:23 2019 UTC

379 struct io_uring_sqe *sqe = iouring_sqe_get (EV_A); 379 struct io_uring_sqe *sqe = iouring_sqe_get (EV_A);
380 sqe->opcode = IORING_OP_POLL_REMOVE; 380 sqe->opcode = IORING_OP_POLL_REMOVE;
381 sqe->fd = fd; 381 sqe->fd = fd;
382 sqe->user_data = -1; 382 sqe->user_data = -1;
383 iouring_sqe_submit (EV_A_ sqe); 383 iouring_sqe_submit (EV_A_ sqe);
384 }
385 384
386 /* increment generation counter to avoid handling old events */ 385 /* increment generation counter to avoid handling old events */
387 ++anfds [fd].egen; 386 ++anfds [fd].egen;
387 }
388 388
389 if (nev) 389 if (nev)
390 { 390 {
391 struct io_uring_sqe *sqe = iouring_sqe_get (EV_A); 391 struct io_uring_sqe *sqe = iouring_sqe_get (EV_A);
392 sqe->opcode = IORING_OP_POLL_ADD; 392 sqe->opcode = IORING_OP_POLL_ADD;
393 sqe->fd = fd; 393 sqe->fd = fd;
394 sqe->user_data = (uint32_t)fd | ((__u64)anfds [fd].egen << 32); 394 sqe->user_data = (uint32_t)fd | ((__u64)(uint32_t)anfds [fd].egen << 32);
395 sqe->poll_events = 395 sqe->poll_events =
396 (nev & EV_READ ? POLLIN : 0) 396 (nev & EV_READ ? POLLIN : 0)
397 | (nev & EV_WRITE ? POLLOUT : 0); 397 | (nev & EV_WRITE ? POLLOUT : 0);
398 iouring_sqe_submit (EV_A_ sqe); 398 iouring_sqe_submit (EV_A_ sqe);
399 } 399 }
442 * to get error codes at all. still, why not document this? 442 * to get error codes at all. still, why not document this?
443 */ 443 */
444 444
445 /* ignore event if generation doesn't match */ 445 /* ignore event if generation doesn't match */
446 /* this should actually be very rare */ 446 /* this should actually be very rare */
447 if (ecb_expect_false ((uint32_t)anfds [fd].egen != gen)) 447 if (ecb_expect_false (gen != (uint32_t)anfds [fd].egen))
448 return; 448 return;
449 449
450 if (ecb_expect_false (res < 0)) 450 if (ecb_expect_false (res < 0))
451 { 451 {
452 if (res == -EINVAL) 452 if (res == -EINVAL)
574static void 574static void
575iouring_poll (EV_P_ ev_tstamp timeout) 575iouring_poll (EV_P_ ev_tstamp timeout)
576{ 576{
577 /* if we have events, no need for extra syscalls, but we might have to queue events */ 577 /* if we have events, no need for extra syscalls, but we might have to queue events */
578 if (iouring_handle_cq (EV_A)) 578 if (iouring_handle_cq (EV_A))
579 timeout = 0.; 579 timeout = EV_TS_CONST (0.);
580 else 580 else
581 /* no events, so maybe wait for some */ 581 /* no events, so maybe wait for some */
582 iouring_tfd_update (EV_A_ timeout); 582 iouring_tfd_update (EV_A_ timeout);
583 583
584 /* only enter the kernel if we have somethign to submit, or we need to wait */ 584 /* only enter the kernel if we have somethign to submit, or we need to wait */
587 int res; 587 int res;
588 588
589 EV_RELEASE_CB; 589 EV_RELEASE_CB;
590 590
591 res = evsys_io_uring_enter (iouring_fd, iouring_to_submit, 1, 591 res = evsys_io_uring_enter (iouring_fd, iouring_to_submit, 1,
592 timeout ? IORING_ENTER_GETEVENTS : 0, 0, 0); 592 timeout > EV_TS_CONST (0.) ? IORING_ENTER_GETEVENTS : 0, 0, 0);
593 iouring_to_submit = 0; 593 iouring_to_submit = 0;
594 594
595 EV_ACQUIRE_CB; 595 EV_ACQUIRE_CB;
596 596
597 if (ecb_expect_false (res < 0)) 597 if (ecb_expect_false (res < 0))
609iouring_init (EV_P_ int flags) 609iouring_init (EV_P_ int flags)
610{ 610{
611 if (!epoll_init (EV_A_ 0)) 611 if (!epoll_init (EV_A_ 0))
612 return 0; 612 return 0;
613 613
614 ev_io_init (EV_A_ &iouring_epoll_w, iouring_epoll_cb, backend_fd, EV_READ); 614 ev_io_init (&iouring_epoll_w, iouring_epoll_cb, backend_fd, EV_READ);
615 ev_set_priority (&iouring_epoll_w, EV_MAXPRI); 615 ev_set_priority (&iouring_epoll_w, EV_MAXPRI);
616 616
617 ev_io_init (&iouring_tfd_w, iouring_tfd_cb, iouring_tfd, EV_READ); 617 ev_io_init (&iouring_tfd_w, iouring_tfd_cb, iouring_tfd, EV_READ);
618 ev_set_priority (&iouring_tfd_w, EV_MAXPRI); 618 ev_set_priority (&iouring_tfd_w, EV_MAXPRI);
619 619

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines