Skip to content

Commit 88fc8b8

Browse files
committed
io_uring/net: initalize msghdr->msg_inq to known value
We can't currently tell if ->msg_inq was set when we ask for msg_get_inq, initialize it to -1U so we can tell apart if it was set and there's no data left, or if it just wasn't set at all by the protocol. Signed-off-by: Jens Axboe <[email protected]>
1 parent bf34e69 commit 88fc8b8

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

io_uring/net.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,7 @@ int io_recvmsg(struct io_kiocb *req, unsigned int issue_flags)
785785
min_ret = iov_iter_count(&kmsg->msg.msg_iter);
786786

787787
kmsg->msg.msg_get_inq = 1;
788+
kmsg->msg.msg_inq = -1U;
788789
if (req->flags & REQ_F_APOLL_MULTISHOT)
789790
ret = io_recvmsg_multishot(sock, sr, kmsg, flags,
790791
&mshot_finished);
@@ -821,7 +822,7 @@ int io_recvmsg(struct io_kiocb *req, unsigned int issue_flags)
821822
io_kbuf_recycle(req, issue_flags);
822823

823824
cflags = io_put_kbuf(req, issue_flags);
824-
if (kmsg->msg.msg_inq)
825+
if (kmsg->msg.msg_inq && kmsg->msg.msg_inq != -1U)
825826
cflags |= IORING_CQE_F_SOCK_NONEMPTY;
826827

827828
if (!io_recv_finish(req, &ret, cflags, mshot_finished, issue_flags))
@@ -882,6 +883,7 @@ int io_recv(struct io_kiocb *req, unsigned int issue_flags)
882883
if (unlikely(ret))
883884
goto out_free;
884885

886+
msg.msg_inq = -1U;
885887
msg.msg_flags = 0;
886888

887889
flags = sr->msg_flags;
@@ -923,7 +925,7 @@ int io_recv(struct io_kiocb *req, unsigned int issue_flags)
923925
io_kbuf_recycle(req, issue_flags);
924926

925927
cflags = io_put_kbuf(req, issue_flags);
926-
if (msg.msg_inq)
928+
if (msg.msg_inq && msg.msg_inq != -1U)
927929
cflags |= IORING_CQE_F_SOCK_NONEMPTY;
928930

929931
if (!io_recv_finish(req, &ret, cflags, ret <= 0, issue_flags))

0 commit comments

Comments
 (0)