summaryrefslogtreecommitdiff
path: root/uring.c
diff options
context:
space:
mode:
Diffstat (limited to 'uring.c')
-rw-r--r--uring.c22
1 files changed, 20 insertions, 2 deletions
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);
}