summaryrefslogtreecommitdiff
path: root/test/timeout-overflow.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/timeout-overflow.c')
-rw-r--r--test/timeout-overflow.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/test/timeout-overflow.c b/test/timeout-overflow.c
index 3d34d36..6445225 100644
--- a/test/timeout-overflow.c
+++ b/test/timeout-overflow.c
@@ -9,9 +9,15 @@
#include "liburing.h"
-#define TIMEOUT_MSEC 1000
+#define TIMEOUT_MSEC 200
static int not_supported;
+static void msec_to_ts(struct __kernel_timespec *ts, unsigned int msec)
+{
+ ts->tv_sec = TIMEOUT_MSEC / 1000;
+ ts->tv_nsec = (msec % 1000) * 1000000;
+}
+
static int check_timeout_support()
{
struct io_uring_sqe *sqe;
@@ -26,8 +32,7 @@ static int check_timeout_support()
return 1;
}
sqe = io_uring_get_sqe(&ring);
- ts.tv_sec = TIMEOUT_MSEC / 1000;
- ts.tv_nsec = 0;
+ msec_to_ts(&ts, TIMEOUT_MSEC);
io_uring_prep_timeout(sqe, &ts, 1, 0);
ret = io_uring_submit(&ring);
@@ -49,8 +54,10 @@ static int check_timeout_support()
}
io_uring_cqe_seen(&ring, cqe);
+ io_uring_queue_exit(&ring);
return 0;
err:
+ io_uring_queue_exit(&ring);
return 1;
}
@@ -80,8 +87,7 @@ static int test_timeout_overflow()
return 1;
}
- ts.tv_sec = TIMEOUT_MSEC / 1000;
- ts.tv_nsec = 0;
+ msec_to_ts(&ts, TIMEOUT_MSEC);
for (i = 0; i < 4; i++) {
unsigned num;
sqe = io_uring_get_sqe(&ring);