blob: 1f69e2083bfb897ae609c761aecf3699a36b98f7 [file] [log] [blame]
Jens Axboe65987012021-01-23 17:03:07 -07001/* SPDX-License-Identifier: MIT */
2/*
3 * Description: Test poll against ring itself. A buggy kernel will end up
4 * having io_wq_* workers pending, as the circular reference
5 * will prevent full exit.
6 *
7 */
8#include <errno.h>
9#include <stdio.h>
10#include <unistd.h>
11#include <stdlib.h>
12#include <string.h>
13#include <sys/poll.h>
14
15#include "liburing.h"
16
17int main(int argc, char *argv[])
18{
19 struct io_uring_sqe *sqe;
20 struct io_uring ring;
21 int ret;
22
23 if (argc > 1)
24 return 0;
25
26 ret = io_uring_queue_init(1, &ring, 0);
27 if (ret) {
28 fprintf(stderr, "child: ring setup failed: %d\n", ret);
29 return 1;
30 }
31
32 sqe = io_uring_get_sqe(&ring);
33 if (!sqe) {
34 fprintf(stderr, "get sqe failed\n");
35 return 1;
36 }
37
38 io_uring_prep_poll_add(sqe, ring.ring_fd, POLLIN);
39 io_uring_sqe_set_data(sqe, sqe);
40
41 ret = io_uring_submit(&ring);
42 if (ret <= 0) {
43 fprintf(stderr, "child: sqe submit failed: %d\n", ret);
44 return 1;
45 }
46
47 return 0;
48}