… | |
… | |
361 | /*****************************************************************************/ |
361 | /*****************************************************************************/ |
362 | |
362 | |
363 | static void |
363 | static void |
364 | iouring_modify (EV_P_ int fd, int oev, int nev) |
364 | iouring_modify (EV_P_ int fd, int oev, int nev) |
365 | { |
365 | { |
366 | fprintf (stderr,"modify %d (%d, %d) %d\n", fd, oev,nev, anfds[fd].eflags);//D |
|
|
367 | if (ecb_expect_false (anfds [fd].eflags)) |
366 | if (ecb_expect_false (anfds [fd].eflags)) |
368 | { |
367 | { |
369 | /* we handed this fd over to epoll, so undo this first */ |
368 | /* we handed this fd over to epoll, so undo this first */ |
370 | /* we do it manually because the optimisations on epoll_modify won't do us any good */ |
369 | /* we do it manually because the optimisations on epoll_modify won't do us any good */ |
371 | epoll_ctl (iouring_fd, EPOLL_CTL_DEL, fd, 0); |
370 | epoll_ctl (iouring_fd, EPOLL_CTL_DEL, fd, 0); |
… | |
… | |
471 | } |
470 | } |
472 | |
471 | |
473 | return; |
472 | return; |
474 | } |
473 | } |
475 | |
474 | |
476 | fprintf (stderr, "fd %d event, rearm\n", fd);//D |
|
|
477 | |
|
|
478 | /* feed events, we do not expect or handle POLLNVAL */ |
475 | /* feed events, we do not expect or handle POLLNVAL */ |
479 | fd_event ( |
476 | fd_event ( |
480 | EV_A_ |
477 | EV_A_ |
481 | fd, |
478 | fd, |
482 | (res & (POLLOUT | POLLERR | POLLHUP) ? EV_WRITE : 0) |
479 | (res & (POLLOUT | POLLERR | POLLHUP) ? EV_WRITE : 0) |
… | |
… | |
579 | timeout = EV_TS_CONST (0.); |
576 | timeout = EV_TS_CONST (0.); |
580 | else |
577 | else |
581 | /* no events, so maybe wait for some */ |
578 | /* no events, so maybe wait for some */ |
582 | iouring_tfd_update (EV_A_ timeout); |
579 | iouring_tfd_update (EV_A_ timeout); |
583 | |
580 | |
584 | /* only enter the kernel if we have somethign to submit, or we need to wait */ |
581 | /* only enter the kernel if we have something to submit, or we need to wait */ |
585 | if (timeout || iouring_to_submit) |
582 | if (timeout || iouring_to_submit) |
586 | { |
583 | { |
587 | int res; |
584 | int res; |
588 | |
585 | |
589 | EV_RELEASE_CB; |
586 | EV_RELEASE_CB; |
… | |
… | |
609 | iouring_init (EV_P_ int flags) |
606 | iouring_init (EV_P_ int flags) |
610 | { |
607 | { |
611 | if (!epoll_init (EV_A_ 0)) |
608 | if (!epoll_init (EV_A_ 0)) |
612 | return 0; |
609 | return 0; |
613 | |
610 | |
|
|
611 | iouring_entries = IOURING_INIT_ENTRIES; |
|
|
612 | iouring_max_entries = 0; |
|
|
613 | |
|
|
614 | if (iouring_internal_init (EV_A) < 0) |
|
|
615 | { |
|
|
616 | iouring_internal_destroy (EV_A); |
|
|
617 | return 0; |
|
|
618 | } |
|
|
619 | |
614 | ev_io_init (EV_A_ &iouring_epoll_w, iouring_epoll_cb, backend_fd, EV_READ); |
620 | ev_io_init (&iouring_epoll_w, iouring_epoll_cb, backend_fd, EV_READ); |
615 | ev_set_priority (&iouring_epoll_w, EV_MAXPRI); |
621 | ev_set_priority (&iouring_epoll_w, EV_MAXPRI); |
616 | |
622 | |
617 | ev_io_init (&iouring_tfd_w, iouring_tfd_cb, iouring_tfd, EV_READ); |
623 | ev_io_init (&iouring_tfd_w, iouring_tfd_cb, iouring_tfd, EV_READ); |
618 | ev_set_priority (&iouring_tfd_w, EV_MAXPRI); |
624 | ev_set_priority (&iouring_tfd_w, EV_MAXPRI); |
619 | |
|
|
620 | iouring_entries = IOURING_INIT_ENTRIES; |
|
|
621 | iouring_max_entries = 0; |
|
|
622 | |
|
|
623 | if (iouring_internal_init (EV_A) < 0) |
|
|
624 | { |
|
|
625 | iouring_internal_destroy (EV_A); |
|
|
626 | return 0; |
|
|
627 | } |
|
|
628 | |
625 | |
629 | ev_io_start (EV_A_ &iouring_epoll_w); |
626 | ev_io_start (EV_A_ &iouring_epoll_w); |
630 | ev_unref (EV_A); /* watcher should not keep loop alive */ |
627 | ev_unref (EV_A); /* watcher should not keep loop alive */ |
631 | |
628 | |
632 | ev_io_start (EV_A_ &iouring_tfd_w); |
629 | ev_io_start (EV_A_ &iouring_tfd_w); |