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

Function test_single_timeout_remove

test/timeout.c:362–435  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

360}
361
362static int test_single_timeout_remove(struct io_uring *ring)
363{
364 struct io_uring_cqe *cqe;
365 struct io_uring_sqe *sqe;
366 struct __kernel_timespec ts;
367 int ret, i;
368
369 sqe = io_uring_get_sqe(ring);
370 if (!sqe) {
371 fprintf(stderr, "%s: get sqe failed\n", __FUNCTION__);
372 goto err;
373 }
374
375 msec_to_ts(&ts, TIMEOUT_MSEC);
376 io_uring_prep_timeout(sqe, &ts, 0, 0);
377 sqe->user_data = 1;
378
379 ret = io_uring_submit(ring);
380 if (ret <= 0) {
381 fprintf(stderr, "%s: sqe submit failed: %d\n", __FUNCTION__, ret);
382 goto err;
383 }
384
385 sqe = io_uring_get_sqe(ring);
386 if (!sqe) {
387 fprintf(stderr, "%s: get sqe failed\n", __FUNCTION__);
388 goto err;
389 }
390
391 io_uring_prep_timeout_remove(sqe, 1, 0);
392 sqe->user_data = 2;
393
394 ret = io_uring_submit(ring);
395 if (ret <= 0) {
396 fprintf(stderr, "%s: sqe submit failed: %d\n", __FUNCTION__, ret);
397 goto err;
398 }
399
400 /*
401 * We should have two completions ready. One is for the original timeout
402 * request, user_data == 1, that should have a ret of -ECANCELED. The other
403 * is for our modify request, user_data == 2, that should have a ret of 0.
404 */
405 for (i = 0; i < 2; i++) {
406 ret = io_uring_wait_cqe(ring, &cqe);
407 if (ret < 0) {
408 fprintf(stderr, "%s: wait completion %d\n", __FUNCTION__, ret);
409 goto err;
410 }
411 if (no_modify)
412 goto seen;
413 if (cqe->res == -EINVAL && cqe->user_data == 2) {
414 fprintf(stdout, "Timeout modify not supported, ignoring\n");
415 no_modify = 1;
416 goto seen;
417 }
418 if (cqe->user_data == 1) {
419 if (cqe->res != -ECANCELED) {

Callers 1

mainFunction · 0.85

Calls 3

io_uring_submitFunction · 0.85
msec_to_tsFunction · 0.70
io_uring_get_sqeFunction · 0.50

Tested by

no test coverage detected