| 60 | } |
| 61 | |
| 62 | static int wait_for(struct io_uring *ring, int fd, int mask) |
| 63 | { |
| 64 | struct io_uring_sqe *sqe; |
| 65 | int ret, res; |
| 66 | |
| 67 | sqe = io_uring_get_sqe(ring); |
| 68 | if (!sqe) { |
| 69 | fprintf(stderr, "unable to get sqe\n"); |
| 70 | return -1; |
| 71 | } |
| 72 | |
| 73 | io_uring_prep_poll_add(sqe, fd, mask); |
| 74 | sqe->user_data = 2; |
| 75 | |
| 76 | ret = submit_and_wait(ring, &res); |
| 77 | if (ret) |
| 78 | return -1; |
| 79 | |
| 80 | if (res < 0) { |
| 81 | fprintf(stderr, "poll(): failed with %d\n", res); |
| 82 | return -1; |
| 83 | } |
| 84 | |
| 85 | return res; |
| 86 | } |
| 87 | |
| 88 | static int listen_on_socket(int fd) |
| 89 | { |
no test coverage detected