Skip to content

Commit

Permalink
io_uring: check file O_NONBLOCK state for accept
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jiufei Xue authored and axboe committed Jun 11, 2020
1 parent 405a5d2 commit e697dee
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions fs/io_uring.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit e697dee

Please sign in to comment.