From e5d833027f7fcdef4d77d26b31b5907873331d0e Mon Sep 17 00:00:00 2001 From: David Härdeman Date: Tue, 16 Jun 2020 10:23:30 +0200 Subject: Add msghdr and iovec to task buffers --- uring.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'uring.c') diff --git a/uring.c b/uring.c index 4c524c7..6c16849 100644 --- a/uring.c +++ b/uring.c @@ -159,6 +159,16 @@ uring_task_get(struct cfg *cfg, struct uring_task *task) void uring_task_set_buf(struct uring_task *task, struct uring_task_buf *tbuf) { + if (tbuf) { + /* iov_len and msg_namelen are set at send/receive time */ + tbuf->iov.iov_base = tbuf->buf; + tbuf->msg.msg_name = &task->addr.storage; + tbuf->msg.msg_iov = &tbuf->iov; + tbuf->msg.msg_iovlen = 1; + tbuf->msg.msg_control = NULL; + tbuf->msg.msg_controllen = 0; + tbuf->msg.msg_flags = 0; + } task->tbuf = tbuf; } @@ -419,13 +429,21 @@ uring_openat(struct cfg *cfg, struct uring_task *task, const char *path, callbac } void -uring_sendmsg(struct cfg *cfg, struct uring_task *task, struct msghdr *msg, callback_t callback) +uring_tbuf_sendmsg(struct cfg *cfg, struct uring_task *task, callback_t callback) { struct io_uring_sqe *sqe; + if (!task->tbuf) { + error("%s: called with no tbuf set\n", __func__); + return; + } + sqe = get_sqe(cfg, task); + task->tbuf->done = 0; + task->tbuf->iov.iov_len = task->tbuf->len; + task->tbuf->msg.msg_namelen = task->addr.addrlen; task->callback = callback; - io_uring_prep_sendmsg(sqe, task->fd, msg, 0); + io_uring_prep_sendmsg(sqe, task->fd, &task->tbuf->msg, 0); io_uring_sqe_set_data(sqe, task); } -- cgit v1.2.3