| 1 |
From 39b7ba58f835eb763b8416c542eef6552dc1ea65 Mon Sep 17 00:00:00 2001 |
| 2 |
From: Yuri Konotopov <[email protected]> |
| 3 |
Date: Fri, 28 Aug 2026 07:51:03 +0000 |
| 4 |
Subject: [PATCH 3/5] Fixed timeout handling on 32 bit platforms |
| 5 |
|
| 6 |
Signed-off-by: Yuri Konotopov <[email protected]> |
| 7 |
|
| 8 |
Forwarded: https://github.com/mosquito/caio/pull/76 |
| 9 |
--- |
| 10 |
caio/linux_aio.c | 12 +++++++++--- |
| 11 |
1 file changed, 9 insertions(+), 3 deletions(-) |
| 12 |
|
| 13 |
diff --git a/caio/linux_aio.c b/caio/linux_aio.c |
| 14 |
index a519b88..cad958c 100644 |
| 15 |
--- a/caio/linux_aio.c |
| 16 |
+++ b/caio/linux_aio.c |
| 17 |
@@ -45,6 +45,12 @@ static const unsigned CTX_MAX_REQUESTS_DEFAULT = 32; |
| 18 |
static const unsigned EV_MAX_REQUESTS_DEFAULT = 512; |
| 19 |
static int kernel_support = -1; |
| 20 |
|
| 21 |
+/* Raw io_getevents uses the kernel's two-long timeout layout. */ |
| 22 |
+struct caio_timespec { |
| 23 |
+ long tv_sec; |
| 24 |
+ long tv_nsec; |
| 25 |
+}; |
| 26 |
+ |
| 27 |
inline static int io_setup(unsigned nr, aio_context_t *ctxp) { |
| 28 |
return syscall(__NR_io_setup, nr, ctxp); |
| 29 |
} |
| 30 |
@@ -57,7 +63,7 @@ inline static int io_destroy(aio_context_t ctx) { |
| 31 |
|
| 32 |
inline static int io_getevents( |
| 33 |
aio_context_t ctx, long min_nr, long max_nr, |
| 34 |
- struct io_event *events, struct timespec *timeout |
| 35 |
+ struct io_event *events, struct caio_timespec *timeout |
| 36 |
) { |
| 37 |
return syscall(__NR_io_getevents, ctx, min_nr, max_nr, events, timeout); |
| 38 |
} |
| 39 |
@@ -463,7 +469,7 @@ static PyObject* AIOContext_process_events( |
| 40 |
uint32_t min_requests = 0; |
| 41 |
uint32_t max_requests = 0; |
| 42 |
int32_t tv_sec = 0; |
| 43 |
- struct timespec timeout = {0, 0}; |
| 44 |
+ struct caio_timespec timeout = {0, 0}; |
| 45 |
|
| 46 |
static char *kwlist[] = {"max_requests", "min_requests", "timeout", NULL}; |
| 47 |
|
| 48 |
@@ -477,7 +483,7 @@ static PyObject* AIOContext_process_events( |
| 49 |
* (unlike linux_uring, whose io_uring_enter() has no native timeout |
| 50 |
* parameter at all). timeout=0 is a non-blocking check; timeout>0 |
| 51 |
* bounds the wait. */ |
| 52 |
- struct timespec *timeout_arg = NULL; |
| 53 |
+ struct caio_timespec *timeout_arg = NULL; |
| 54 |
if (tv_sec >= 0) { |
| 55 |
timeout.tv_sec = tv_sec; |
| 56 |
timeout_arg = &timeout; |
| 57 |
-- |
| 58 |
2.55.0 |
| 59 |
|