public inbox for [email protected]
 help / color / mirror / Atom feed
From: Jens Axboe <[email protected]>
To: io-uring <[email protected]>
Subject: [PATCH] io_uring: include file O_NONBLOCK state for recv/send
Date: Fri, 22 May 2020 13:15:57 -0600	[thread overview]
Message-ID: <[email protected]> (raw)

We only check for MSG_DONTWAIT in terms of whether or not we should
be completing with -EAGAIN or retrying, ensure that we check the
file O_NONBLOCK flag as well.

Cc: [email protected] # v5.6+
Fixes: fddafacee287 ("io_uring: add support for send(2) and recv(2)")
Signed-off-by: Jens Axboe <[email protected]>
---
 fs/io_uring.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/io_uring.c b/fs/io_uring.c
index 792720b2c01e..bf75ac753b9d 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -3702,7 +3702,7 @@ static int io_send(struct io_kiocb *req, bool force_nonblock)
 		msg.msg_namelen = 0;
 
 		flags = req->sr_msg.msg_flags;
-		if (flags & MSG_DONTWAIT)
+		if ((flags & MSG_DONTWAIT) || (req->file->f_flags & O_NONBLOCK))
 			req->flags |= REQ_F_NOWAIT;
 		else if (force_nonblock)
 			flags |= MSG_DONTWAIT;
@@ -3961,7 +3961,7 @@ static int io_recv(struct io_kiocb *req, bool force_nonblock)
 		msg.msg_flags = 0;
 
 		flags = req->sr_msg.msg_flags;
-		if (flags & MSG_DONTWAIT)
+		if ((flags & MSG_DONTWAIT) || (req->file->f_flags & O_NONBLOCK))
 			req->flags |= REQ_F_NOWAIT;
 		else if (force_nonblock)
 			flags |= MSG_DONTWAIT;
-- 
2.26.2

-- 
Jens Axboe


                 reply	other threads:[~2020-05-22 19:16 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    [email protected] \
    [email protected] \
    [email protected] \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox