summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHao Xu <howeyxu@tencent.com>2022-05-14 22:35:30 +0800
committerJens Axboe <axboe@kernel.dk>2022-05-14 09:15:38 -0600
commite7c7089e352f5a6ead9c409a7d8a43ffe9cd59a5 (patch)
tree1e451e9b1738bae6cc33999b326b23e7a18faad8
parent19b0d25193330d3cfcd636d4cc2e4ec1ec019271 (diff)
downloadliburing-e7c7089e352f5a6ead9c409a7d8a43ffe9cd59a5.tar.gz
liburing-e7c7089e352f5a6ead9c409a7d8a43ffe9cd59a5.tar.bz2
liburing.h: support multishot accept
Add a new api to leverage the multishot mode accept, this feature is to achieve one accept request for all listened events. Signed-off-by: Hao Xu <howeyxu@tencent.com> Link: https://lore.kernel.org/r/20220514143534.59162-3-haoxu.linux@gmail.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--src/include/liburing.h10
-rw-r--r--src/include/liburing/io_uring.h5
2 files changed, 15 insertions, 0 deletions
diff --git a/src/include/liburing.h b/src/include/liburing.h
index 5c03061..cf50383 100644
--- a/src/include/liburing.h
+++ b/src/include/liburing.h
@@ -502,6 +502,16 @@ static inline void io_uring_prep_accept_direct(struct io_uring_sqe *sqe, int fd,
__io_uring_set_target_fixed_file(sqe, file_index);
}
+static inline void io_uring_prep_multishot_accept(struct io_uring_sqe *sqe,
+ int fd, struct sockaddr *addr,
+ socklen_t *addrlen, int flags)
+{
+ io_uring_prep_rw(IORING_OP_ACCEPT, sqe, fd, addr, 0,
+ (__u64) (unsigned long) addrlen);
+ sqe->accept_flags = (__u32) flags;
+ sqe->ioprio |= IORING_ACCEPT_MULTISHOT;
+}
+
static inline void io_uring_prep_cancel(struct io_uring_sqe *sqe,
__u64 user_data, int flags)
{
diff --git a/src/include/liburing/io_uring.h b/src/include/liburing/io_uring.h
index bfb3548..46765d2 100644
--- a/src/include/liburing/io_uring.h
+++ b/src/include/liburing/io_uring.h
@@ -434,6 +434,11 @@ struct io_uring_getevents_arg {
__u64 ts;
};
+/*
+ * accept flags stored in sqe->ioprio
+ */
+#define IORING_ACCEPT_MULTISHOT (1U << 0)
+
#ifdef __cplusplus
}
#endif