diff options
author | Jens Axboe <axboe@kernel.dk> | 2024-02-19 14:53:37 -0700 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2024-02-19 14:53:37 -0700 |
commit | af77bf2a82d2e71ffd1c353114ec24634c6e6d25 (patch) | |
tree | 18a9ad9470ad33b53438e5f542d16a0edd26d875 | |
parent | 4e6429586d5a08371f7c7a84de1e84523e5b5720 (diff) | |
download | liburing-af77bf2a82d2e71ffd1c353114ec24634c6e6d25.tar.gz |
examples/proxy: set 'len' for ring provided send buffers
Normally 'ret' == buf_size, but if it's a short receive, we do need to
cap the send length to what we received.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r-- | examples/proxy.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/examples/proxy.c b/examples/proxy.c index 525f3003..24a92818 100644 --- a/examples/proxy.c +++ b/examples/proxy.c @@ -690,18 +690,14 @@ static void __queue_send(struct io_uring *ring, struct conn *c, int fd, sqe = get_sqe(ring); if (use_msg) { memset(&msg, 0, sizeof(msg)); - if (!send_ring) { - iov.iov_base = data; - iov.iov_len = len; - msg.msg_iov = &iov; - msg.msg_iovlen = 1; - } + iov.iov_base = data; + iov.iov_len = len; + msg.msg_iov = &iov; + msg.msg_iovlen = 1; io_uring_prep_sendmsg(sqe, fd, &msg, MSG_WAITALL | MSG_NOSIGNAL); } else { - if (send_ring) { + if (send_ring) data = NULL; - len = 0; - } io_uring_prep_send(sqe, fd, data, len, MSG_WAITALL | MSG_NOSIGNAL); } encode_userdata(sqe, c, __SEND, bid, fd); |