diff options
author | Jens Axboe <axboe@kernel.dk> | 2019-09-15 21:47:48 -0600 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2019-09-15 21:47:48 -0600 |
commit | e4d4843db77ab74822f151e214783ba0045515f1 (patch) | |
tree | 2b142a5479ffa148cfb49fe14f3bae7661ba6f52 | |
parent | ca50c1f776bf20678668dafbb99998741724639b (diff) | |
parent | 6e68fda171686653af586ffd086d14100eefeda5 (diff) | |
download | liburing-e4d4843db77ab74822f151e214783ba0045515f1.tar.gz liburing-e4d4843db77ab74822f151e214783ba0045515f1.tar.bz2 |
Merge branch 'master' of https://github.com/CarterLi/liburing
* 'master' of https://github.com/CarterLi/liburing:
liburing: add io_uring_prep_{recv,send}msg
-rw-r--r-- | src/include/liburing.h | 15 | ||||
-rw-r--r-- | test/send_recvmsg.c | 12 |
2 files changed, 17 insertions, 10 deletions
diff --git a/src/include/liburing.h b/src/include/liburing.h index 7d884c9..c4189b1 100644 --- a/src/include/liburing.h +++ b/src/include/liburing.h @@ -5,6 +5,7 @@ extern "C" { #endif +#include <sys/socket.h> #include <sys/uio.h> #include <signal.h> #include <string.h> @@ -187,6 +188,20 @@ static inline void io_uring_prep_write_fixed(struct io_uring_sqe *sqe, int fd, sqe->buf_index = buf_index; } +static inline void io_uring_prep_recvmsg(struct io_uring_sqe *sqe, int fd, + struct msghdr *msg, unsigned flags) +{ + io_uring_prep_rw(IORING_OP_RECVMSG, sqe, fd, msg, 1, 0); + sqe->msg_flags = flags; +} + +static inline void io_uring_prep_sendmsg(struct io_uring_sqe *sqe, int fd, + const struct msghdr *msg, unsigned flags) +{ + io_uring_prep_rw(IORING_OP_SENDMSG, sqe, fd, msg, 1, 0); + sqe->msg_flags = flags; +} + static inline void io_uring_prep_poll_add(struct io_uring_sqe *sqe, int fd, short poll_mask) { diff --git a/test/send_recvmsg.c b/test/send_recvmsg.c index ada6559..9b67b61 100644 --- a/test/send_recvmsg.c +++ b/test/send_recvmsg.c @@ -61,11 +61,7 @@ static int do_recvmsg(void) msg.msg_iovlen = 1; sqe = io_uring_get_sqe(&ring); - memset(sqe, 0, sizeof(*sqe)); - sqe->opcode = IORING_OP_RECVMSG; - sqe->fd = sockfd; - sqe->addr = (uintptr_t) &msg; - sqe->len = 1; + io_uring_prep_recvmsg(sqe, sockfd, &msg, 0); ret = io_uring_submit(&ring); if (ret <= 0) { @@ -133,11 +129,7 @@ static int do_sendmsg(void) } sqe = io_uring_get_sqe(&ring); - memset(sqe, 0, sizeof(*sqe)); - sqe->opcode = IORING_OP_SENDMSG; - sqe->fd = sockfd; - sqe->addr = (uintptr_t) &msg; - sqe->len = 1; + io_uring_prep_sendmsg(sqe, sockfd, &msg, 0); ret = io_uring_submit(&ring); if (ret <= 0) { |