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

Function main

examples/io_uring-udp.c:325–403  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

323}
324
325int main(int argc, char *argv[])
326{
327 struct ctx ctx;
328 int ret;
329 int port = -1;
330 int sockfd;
331 int opt;
332 struct io_uring_cqe *cqes[CQES];
333 unsigned int count, i;
334
335 memset(&ctx, 0, sizeof(ctx));
336 ctx.verbose = false;
337 ctx.af = AF_INET;
338 ctx.buf_shift = BUF_SHIFT;
339
340 while ((opt = getopt(argc, argv, "6vp:b:")) != -1) {
341 switch (opt) {
342 case '6':
343 ctx.af = AF_INET6;
344 break;
345 case 'p':
346 port = atoi(optarg);
347 break;
348 case 'b':
349 ctx.buf_shift = atoi(optarg);
350 break;
351 case 'v':
352 ctx.verbose = true;
353 break;
354 default:
355 fprintf(stderr, "Usage: %s [-p port] "
356 "[-b log2(BufferSize)] [-6] [-v]\n",
357 argv[0]);
358 exit(-1);
359 }
360 }
361
362 sockfd = setup_sock(ctx.af, port);
363 if (sockfd < 0)
364 return 1;
365
366 if (setup_context(&ctx)) {
367 close(sockfd);
368 return 1;
369 }
370
371 ret = io_uring_register_files(&ctx.ring, &sockfd, 1);
372 if (ret) {
373 fprintf(stderr, "register files: %s\n", strerror(-ret));
374 return -1;
375 }
376
377 ret = add_recv(&ctx, 0);
378 if (ret)
379 return 1;
380
381 while (true) {
382 ret = io_uring_submit_and_wait(&ctx.ring, 1);

Callers

nothing calls this directly

Calls 8

setup_sockFunction · 0.85
io_uring_register_filesFunction · 0.85
io_uring_submit_and_waitFunction · 0.85
io_uring_peek_batch_cqeFunction · 0.85
process_cqeFunction · 0.85
cleanup_contextFunction · 0.85
setup_contextFunction · 0.70
add_recvFunction · 0.70

Tested by

no test coverage detected