• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: MIT */
2 /*
3  * Test if entering with nothing to submit/wait for SQPOLL returns an error.
4  */
5 #include <stdio.h>
6 #include <errno.h>
7 #include <string.h>
8 
9 #include "liburing.h"
10 #include "helpers.h"
11 #include "../src/syscall.h"
12 
main(int argc,char * argv[])13 int main(int argc, char *argv[])
14 {
15 	struct io_uring_params p = {};
16 	struct io_uring ring;
17 	int ret;
18 
19 	if (argc > 1)
20 		return 0;
21 
22 	p.flags = IORING_SETUP_SQPOLL;
23 	p.sq_thread_idle = 100;
24 
25 	ret = t_create_ring_params(1, &ring, &p);
26 	if (ret == T_SETUP_SKIP)
27 		return 0;
28 	else if (ret < 0)
29 		goto err;
30 
31 	ret = __sys_io_uring_enter(ring.ring_fd, 0, 0, 0, NULL);
32 	if (ret < 0) {
33 		int __e = errno;
34 
35 		if (__e == EOWNERDEAD)
36 			fprintf(stderr, "sqe submit unexpected failure due old kernel bug: %s\n", strerror(__e));
37 		else
38 			fprintf(stderr, "sqe submit unexpected failure: %s\n", strerror(__e));
39 		goto err;
40 	}
41 
42 	return 0;
43 err:
44 	return 1;
45 }
46