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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Hao Xu <howeyxu@xxxxxxxxxxx>

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

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
-- 
2.36.0




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux