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

Function test_loop

test/accept.c:256–372  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

254}
255
256static int test_loop(struct io_uring *ring,
257 struct accept_test_args args,
258 int recv_s0,
259 struct sockaddr_in *addr)
260{
261 struct io_uring_cqe *cqe;
262 uint32_t head, count = 0;
263 int i, ret, s_fd[MAX_FDS], c_fd[MAX_FDS], done = 0;
264 bool fixed = args.fixed;
265 bool multishot = args.multishot;
266 uint32_t multishot_mask = 0;
267 int nr_fds = multishot ? MAX_FDS : 1;
268 int multishot_idx = multishot ? INITIAL_USER_DATA : 0;
269 int err_ret = T_EXIT_FAIL;
270 void* send_d = 0;
271 void* recv_d = 0;
272
273 if (args.overflow)
274 cause_overflow(ring);
275
276 for (i = 0; i < nr_fds; i++) {
277 c_fd[i] = set_client_fd(addr);
278 if (args.overflow && i == nr_fds / 2)
279 clear_overflow(ring);
280 }
281
282 if (!args.queue_accept_before_connect)
283 queue_accept_conn(ring, recv_s0, args);
284
285 for (i = 0; i < nr_fds; i++) {
286 s_fd[i] = accept_conn(ring, fixed ? 0 : -1, &multishot_idx, recv_s0);
287 if (s_fd[i] == -EINVAL) {
288 if (args.accept_should_error)
289 goto out;
290 fprintf(stdout,
291 "%s %s Accept not supported, skipping\n",
292 fixed ? "Fixed" : "",
293 multishot ? "Multishot" : "");
294 if (multishot)
295 no_accept_multi = 1;
296 else
297 no_accept = 1;
298 ret = T_EXIT_SKIP;
299 goto out;
300 } else if (s_fd[i] < 0) {
301 if (args.accept_should_error &&
302 (s_fd[i] == -EBADF || s_fd[i] == -EINVAL))
303 goto out;
304 fprintf(stderr, "%s %s Accept[%d] got %d\n",
305 fixed ? "Fixed" : "",
306 multishot ? "Multishot" : "",
307 i, s_fd[i]);
308 goto err;
309 } else if (s_fd[i] == 195 && args.overflow) {
310 fprintf(stderr, "Broken overflow handling\n");
311 goto err;
312 }
313

Callers 1

testFunction · 0.85

Calls 9

cause_overflowFunction · 0.85
set_client_fdFunction · 0.85
clear_overflowFunction · 0.85
queue_accept_connFunction · 0.85
accept_connFunction · 0.85
queue_recvFunction · 0.85
io_uring_submit_and_waitFunction · 0.85
close_sock_fdsFunction · 0.85
queue_sendFunction · 0.70

Tested by

no test coverage detected