| 323 | } |
| 324 | |
| 325 | int 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); |
nothing calls this directly
no test coverage detected