MCPcopy Create free account
hub / github.com/axboe/liburing / test_maccept

Function test_maccept

test/accept-non-empty.c:102–194  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

100}
101
102static int test_maccept(struct data *d, int flags, int fixed)
103{
104 struct io_uring_params p = { };
105 struct io_uring ring;
106 struct io_uring_cqe *cqe;
107 struct io_uring_sqe *sqe;
108 int err = 0, fd, ret, i, *fds;
109
110 p.flags = flags;
111 ret = io_uring_queue_init_params(8, &ring, &p);
112 if (ret == -EINVAL) {
113 return T_EXIT_SKIP;
114 } else if (ret < 0) {
115 fprintf(stderr, "ring setup failure: %d\n", ret);
116 return T_EXIT_FAIL;
117 }
118
119 if (!(p.features & IORING_FEAT_RECVSEND_BUNDLE)) {
120 no_more_accept = 1;
121 return 0;
122 }
123
124 setup_thread(d, MAX_ACCEPTS);
125
126 fds = malloc(MAX_ACCEPTS * sizeof(int));
127 memset(fds, -1, MAX_ACCEPTS * sizeof(int));
128
129 if (fixed) {
130 io_uring_register_ring_fd(&ring);
131
132 ret = io_uring_register_files(&ring, fds, MAX_ACCEPTS);
133 if (ret) {
134 fprintf(stderr, "file reg %d\n", ret);
135 return -1;
136 }
137 }
138
139 fd = start_accept_listen(0, 0);
140
141 pthread_barrier_wait(&d->barrier);
142
143 if (d->connects > 1)
144 pthread_barrier_wait(&d->conn_barrier);
145
146 for (i = 0; i < d->connects; i++) {
147 sqe = io_uring_get_sqe(&ring);
148 if (fixed)
149 io_uring_prep_accept_direct(sqe, fd, NULL, NULL, 0, i);
150 else
151 io_uring_prep_accept(sqe, fd, NULL, NULL, 0);
152
153 ret = io_uring_submit_and_wait(&ring, 1);
154 assert(ret != -1);
155
156 ret = io_uring_wait_cqe(&ring, &cqe);
157 assert(!ret);
158 if (cqe->res < 0) {
159 fprintf(stderr, "res=%d\n", cqe->res);

Callers 1

testFunction · 0.85

Calls 8

setup_threadFunction · 0.85
io_uring_register_filesFunction · 0.85
io_uring_submit_and_waitFunction · 0.85
io_uring_queue_exitFunction · 0.85
start_accept_listenFunction · 0.70
io_uring_get_sqeFunction · 0.50

Tested by

no test coverage detected