From e8758c9b5f68f211b9c3183139d72405904c3a32 Mon Sep 17 00:00:00 2001 From: Jiufei Xue Date: Wed, 10 Jun 2020 13:26:41 +0800 Subject: [PATCH 1382/2944] io_uring: check file O_NONBLOCK state for accept task #27774850 commit e697deed834de15d2322d0619d51893022c90ea2 upstream. If the socket is O_NONBLOCK, we should complete the accept request with -EAGAIN when data is not ready. Signed-off-by: Jiufei Xue Signed-off-by: Jens Axboe Reviewed-by: Joseph Qi --- fs/io_uring.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/io_uring.c b/fs/io_uring.c index 17d472f..d73a90d 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -3969,6 +3969,9 @@ static int io_accept(struct io_kiocb *req, bool force_nonblock) { int ret; + if (req->file->f_flags & O_NONBLOCK) + req->flags |= REQ_F_NOWAIT; + ret = __io_accept(req, force_nonblock); if (ret == -EAGAIN && force_nonblock) { req->work.func = io_accept_finish; -- 1.8.3.1