Skip to contentSkip to conversation

io_uring: include file O_NONBLOCK state for recv/send

PATCH New Jens Axboe 1 participant 1 message May 22, 2020

Subsystems (2)
lore
Share & tools
lore

Jens Axboe

author maintainer
#0 lore raw

PATCH 1/1 io_uring: include file O_NONBLOCK state for recv/send

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.

Fixes fddafacee287 ("io_uring: add support for send(2) and recv(2)")
---
 fs/io_uring.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/io_uring.c +2 -2
index 792720b2c01e..bf75ac753b9d 100644
@@ -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;
Signature · 4 lines
2.26.2

-- 
Jens Axboe