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

Function test_update_timeout

test/timeout.c:973–1085  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

971}
972
973static int test_update_timeout(struct io_uring *ring, unsigned long ms,
974 bool abs, bool async, bool linked)
975{
976 struct io_uring_sqe *sqe;
977 struct io_uring_cqe *cqe;
978 struct __kernel_timespec ts, ts_upd;
979 unsigned long long exp_ms, base_ms = 10000;
980 bool update_ealready = false;
981 struct timeval tv;
982 int ret, i, nr = 2;
983 __u32 mode = abs ? IORING_TIMEOUT_ABS : 0;
984
985 msec_to_ts(&ts_upd, ms);
986 gettimeofday(&tv, NULL);
987
988 sqe = io_uring_get_sqe(ring);
989 if (!sqe) {
990 fprintf(stderr, "%s: get sqe failed\n", __FUNCTION__);
991 goto err;
992 }
993 msec_to_ts(&ts, base_ms);
994 io_uring_prep_timeout(sqe, &ts, 0, 0);
995 sqe->user_data = 1;
996
997 if (linked) {
998 sqe = io_uring_get_sqe(ring);
999 if (!sqe) {
1000 fprintf(stderr, "%s: get sqe failed\n", __FUNCTION__);
1001 goto err;
1002 }
1003 io_uring_prep_nop(sqe);
1004 sqe->user_data = 3;
1005 sqe->flags = IOSQE_IO_LINK;
1006 if (async)
1007 sqe->flags |= IOSQE_ASYNC;
1008 nr++;
1009 }
1010
1011 sqe = io_uring_get_sqe(ring);
1012 if (!sqe) {
1013 fprintf(stderr, "%s: get sqe failed\n", __FUNCTION__);
1014 goto err;
1015 }
1016 io_uring_prep_timeout_update(sqe, &ts_upd, 1, mode);
1017 sqe->user_data = 2;
1018 if (async)
1019 sqe->flags |= IOSQE_ASYNC;
1020
1021 ret = io_uring_submit(ring);
1022 if (ret != nr) {
1023 fprintf(stderr, "%s: sqe submit failed: %d\n", __FUNCTION__, ret);
1024 goto err;
1025 }
1026
1027 for (i = 0; i < nr; i++) {
1028 ret = io_uring_wait_cqe(ring, &cqe);
1029 if (ret < 0) {
1030 fprintf(stderr, "%s: wait completion %d\n", __FUNCTION__, ret);

Callers 1

mainFunction · 0.85

Calls 4

io_uring_submitFunction · 0.85
msec_to_tsFunction · 0.70
mtime_since_nowFunction · 0.70
io_uring_get_sqeFunction · 0.50

Tested by

no test coverage detected