summaryrefslogtreecommitdiff
path: root/fs
diff options
context:
space:
mode:
authorJiufei Xue <jiufei.xue@linux.alibaba.com>2020-06-10 13:41:59 +0800
committerJens Axboe <axboe@kernel.dk>2020-06-10 18:06:16 -0600
commite697deed834de15d2322d0619d51893022c90ea2 (patch)
tree686a3c4003efa9d74e3f7658c5b3b3bebf854dbd /fs
parent405a5d2b2762f2a9813efdee93274d4e7bf607a1 (diff)
io_uring: check file O_NONBLOCK state for accept
If the socket is O_NONBLOCK, we should complete the accept request with -EAGAIN when data is not ready. Signed-off-by: Jiufei Xue <jiufei.xue@linux.alibaba.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'fs')
-rw-r--r--fs/io_uring.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c
index d72b2a9463ca..5b0249140ff5 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -3909,6 +3909,9 @@ static int io_accept(struct io_kiocb *req, bool force_nonblock)
unsigned int file_flags = force_nonblock ? O_NONBLOCK : 0;
int ret;
+ if (req->file->f_flags & O_NONBLOCK)
+ req->flags |= REQ_F_NOWAIT;
+
ret = __sys_accept4_file(req->file, file_flags, accept->addr,
accept->addr_len, accept->flags,
accept->nofile);