| 290 | } |
| 291 | |
| 292 | static int test_single_timeout_remove_notfound(struct io_uring *ring) |
| 293 | { |
| 294 | struct io_uring_cqe *cqe; |
| 295 | struct io_uring_sqe *sqe; |
| 296 | struct __kernel_timespec ts; |
| 297 | int ret, i; |
| 298 | |
| 299 | if (no_modify) |
| 300 | return 0; |
| 301 | |
| 302 | sqe = io_uring_get_sqe(ring); |
| 303 | if (!sqe) { |
| 304 | fprintf(stderr, "%s: get sqe failed\n", __FUNCTION__); |
| 305 | goto err; |
| 306 | } |
| 307 | |
| 308 | msec_to_ts(&ts, TIMEOUT_MSEC); |
| 309 | io_uring_prep_timeout(sqe, &ts, 2, 0); |
| 310 | sqe->user_data = 1; |
| 311 | |
| 312 | ret = io_uring_submit(ring); |
| 313 | if (ret <= 0) { |
| 314 | fprintf(stderr, "%s: sqe submit failed: %d\n", __FUNCTION__, ret); |
| 315 | goto err; |
| 316 | } |
| 317 | |
| 318 | sqe = io_uring_get_sqe(ring); |
| 319 | if (!sqe) { |
| 320 | fprintf(stderr, "%s: get sqe failed\n", __FUNCTION__); |
| 321 | goto err; |
| 322 | } |
| 323 | |
| 324 | io_uring_prep_timeout_remove(sqe, 2, 0); |
| 325 | sqe->user_data = 2; |
| 326 | |
| 327 | ret = io_uring_submit(ring); |
| 328 | if (ret <= 0) { |
| 329 | fprintf(stderr, "%s: sqe submit failed: %d\n", __FUNCTION__, ret); |
| 330 | goto err; |
| 331 | } |
| 332 | |
| 333 | /* |
| 334 | * We should get two completions. One is our modify request, which should |
| 335 | * complete with -ENOENT. The other is the timeout that will trigger after |
| 336 | * TIMEOUT_MSEC. |
| 337 | */ |
| 338 | for (i = 0; i < 2; i++) { |
| 339 | ret = io_uring_wait_cqe(ring, &cqe); |
| 340 | if (ret < 0) { |
| 341 | fprintf(stderr, "%s: wait completion %d\n", __FUNCTION__, ret); |
| 342 | goto err; |
| 343 | } |
| 344 | if (cqe->user_data == 2) { |
| 345 | if (cqe->res != -ENOENT) { |
| 346 | fprintf(stderr, "%s: modify ret %d, wanted ENOENT\n", __FUNCTION__, cqe->res); |
| 347 | break; |
| 348 | } |
| 349 | } else if (cqe->user_data == 1) { |
no test coverage detected