Skip to content

Commit 7d41bcb

Browse files
committed
io_uring/net: push IORING_CQE_F_SOCK_NONEMPTY into io_recv_finish()
Rather than have this logic in both io_recv() and io_recvmsg_multishot(), push it into the handler they both call when finishing a receive operation. Signed-off-by: Jens Axboe <[email protected]>
1 parent 88fc8b8 commit 7d41bcb

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

io_uring/net.c

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -616,9 +616,15 @@ static inline void io_recv_prep_retry(struct io_kiocb *req)
616616
* again (for multishot).
617617
*/
618618
static inline bool io_recv_finish(struct io_kiocb *req, int *ret,
619-
unsigned int cflags, bool mshot_finished,
619+
struct msghdr *msg, bool mshot_finished,
620620
unsigned issue_flags)
621621
{
622+
unsigned int cflags;
623+
624+
cflags = io_put_kbuf(req, issue_flags);
625+
if (msg->msg_inq && msg->msg_inq != -1U)
626+
cflags |= IORING_CQE_F_SOCK_NONEMPTY;
627+
622628
if (!(req->flags & REQ_F_APOLL_MULTISHOT)) {
623629
io_req_set_res(req, *ret, cflags);
624630
*ret = IOU_OK;
@@ -732,7 +738,6 @@ int io_recvmsg(struct io_kiocb *req, unsigned int issue_flags)
732738
struct io_sr_msg *sr = io_kiocb_to_cmd(req, struct io_sr_msg);
733739
struct io_async_msghdr iomsg, *kmsg;
734740
struct socket *sock;
735-
unsigned int cflags;
736741
unsigned flags;
737742
int ret, min_ret = 0;
738743
bool force_nonblock = issue_flags & IO_URING_F_NONBLOCK;
@@ -821,11 +826,7 @@ int io_recvmsg(struct io_kiocb *req, unsigned int issue_flags)
821826
else
822827
io_kbuf_recycle(req, issue_flags);
823828

824-
cflags = io_put_kbuf(req, issue_flags);
825-
if (kmsg->msg.msg_inq && kmsg->msg.msg_inq != -1U)
826-
cflags |= IORING_CQE_F_SOCK_NONEMPTY;
827-
828-
if (!io_recv_finish(req, &ret, cflags, mshot_finished, issue_flags))
829+
if (!io_recv_finish(req, &ret, &kmsg->msg, mshot_finished, issue_flags))
829830
goto retry_multishot;
830831

831832
if (mshot_finished) {
@@ -844,7 +845,6 @@ int io_recv(struct io_kiocb *req, unsigned int issue_flags)
844845
struct io_sr_msg *sr = io_kiocb_to_cmd(req, struct io_sr_msg);
845846
struct msghdr msg;
846847
struct socket *sock;
847-
unsigned int cflags;
848848
unsigned flags;
849849
int ret, min_ret = 0;
850850
bool force_nonblock = issue_flags & IO_URING_F_NONBLOCK;
@@ -924,11 +924,7 @@ int io_recv(struct io_kiocb *req, unsigned int issue_flags)
924924
else
925925
io_kbuf_recycle(req, issue_flags);
926926

927-
cflags = io_put_kbuf(req, issue_flags);
928-
if (msg.msg_inq && msg.msg_inq != -1U)
929-
cflags |= IORING_CQE_F_SOCK_NONEMPTY;
930-
931-
if (!io_recv_finish(req, &ret, cflags, ret <= 0, issue_flags))
927+
if (!io_recv_finish(req, &ret, &msg, ret <= 0, issue_flags))
932928
goto retry_multishot;
933929

934930
return ret;

0 commit comments

Comments
 (0)