diff mbox series

[2/6] liburing.h: support multishot accept

Message ID 20220514143534.59162-3-haoxu.linux@gmail.com (mailing list archive)
State New
Headers show
Series liburing changes for multishot accept | expand

Commit Message

Hao Xu May 14, 2022, 2:35 p.m. UTC
From: Hao Xu <howeyxu@tencent.com>

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>
---
 src/include/liburing.h          | 10 ++++++++++
 src/include/liburing/io_uring.h |  5 +++++
 2 files changed, 15 insertions(+)
diff mbox series

Patch

diff --git a/src/include/liburing.h b/src/include/liburing.h
index 5c03061388aa..cf50383c8e63 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 bfb3548fff96..46765d2697ba 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