From 236426f95e742c91cb135251b5e9598dd7fa885d Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Sun, 23 May 2021 12:25:46 -0400 Subject: [PATCH] linux::io_uring: add link_timeout Signed-off-by: Drew DeVault --- io_uring/sqe.ha | 15 +++++++++++++++ diff --git a/io_uring/sqe.ha b/io_uring/sqe.ha index efea2460461f4a87e212db26f73d31c4c5cdb1ad..c2517d8cdc568b48134a011c0485231fa9e8aedb 100644 --- a/io_uring/sqe.ha +++ b/io_uring/sqe.ha @@ -256,6 +256,21 @@ sqe.timeout_flags = to_flags | timeout_flags::UPDATE; sqe.addr2 = ts; }; +// Prepares a timeout operation for an [[sqe]] which is linked to the previous +// SQE, effectively setting an upper limit on how long that SQE can take to +// complete. "ts" should be a timespec describing the desired timeout. The +// caller must call [[setuser]] to provide a user data field in order to use +// [[timeout_remove]] to cancel this timeout later. +export fn link_timeout( + sqe: *sqe, + ts: *rt::timespec, + to_flags: timeout_flags, + flags: flags... +) void = { + preprw(sqe, op::LINK_TIMEOUT, 0, ts, 1, 0, flags...); + sqe.timeout_flags = to_flags; +}; + // Prepares a socket accept operation for an [[sqe]]. Equivalent to accept4(2). export fn accept( sqe: *sqe, -- 2.48.1