| 539 | } |
| 540 | |
| 541 | static int test_link_timeout_update(struct io_uring *ring, int async) |
| 542 | { |
| 543 | struct __kernel_timespec ts; |
| 544 | struct io_uring_cqe *cqe; |
| 545 | struct io_uring_sqe *sqe; |
| 546 | struct timeval start; |
| 547 | unsigned long msec; |
| 548 | int fds[2], ret, i; |
| 549 | struct iovec iov; |
| 550 | char buffer[128]; |
| 551 | |
| 552 | if (pipe(fds)) { |
| 553 | perror("pipe"); |
| 554 | return 1; |
| 555 | } |
| 556 | |
| 557 | sqe = io_uring_get_sqe(ring); |
| 558 | if (!sqe) { |
| 559 | printf("get sqe failed\n"); |
| 560 | goto err; |
| 561 | } |
| 562 | iov.iov_base = buffer; |
| 563 | iov.iov_len = sizeof(buffer); |
| 564 | io_uring_prep_readv(sqe, fds[0], &iov, 1, 0); |
| 565 | sqe->flags |= IOSQE_IO_LINK; |
| 566 | sqe->user_data = 1; |
| 567 | |
| 568 | sqe = io_uring_get_sqe(ring); |
| 569 | if (!sqe) { |
| 570 | printf("get sqe failed\n"); |
| 571 | goto err; |
| 572 | } |
| 573 | ts.tv_sec = 5; |
| 574 | ts.tv_nsec = 0; |
| 575 | io_uring_prep_link_timeout(sqe, &ts, 0); |
| 576 | sqe->user_data = 2; |
| 577 | |
| 578 | ret = io_uring_submit(ring); |
| 579 | if (ret != 2) { |
| 580 | printf("sqe submit failed: %d\n", ret); |
| 581 | goto err; |
| 582 | } |
| 583 | |
| 584 | ts.tv_sec = 0; |
| 585 | ts.tv_nsec = 100000000LL; |
| 586 | sqe = io_uring_get_sqe(ring); |
| 587 | io_uring_prep_timeout_update(sqe, &ts, 2, IORING_LINK_TIMEOUT_UPDATE); |
| 588 | if (async) |
| 589 | sqe->flags |= IOSQE_ASYNC; |
| 590 | sqe->user_data = 3; |
| 591 | |
| 592 | io_uring_submit(ring); |
| 593 | |
| 594 | gettimeofday(&start, NULL); |
| 595 | for (i = 0; i < 3; i++) { |
| 596 | ret = io_uring_wait_cqe(ring, &cqe); |
| 597 | if (ret < 0) { |
| 598 | printf("wait completion %d\n", ret); |
no test coverage detected