Skip to content

Commit e697dee

Browse files
Jiufei Xueaxboe
authored andcommitted
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 <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 405a5d2 commit e697dee

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

fs/io_uring.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3909,6 +3909,9 @@ static int io_accept(struct io_kiocb *req, bool force_nonblock)
39093909
unsigned int file_flags = force_nonblock ? O_NONBLOCK : 0;
39103910
int ret;
39113911

3912+
if (req->file->f_flags & O_NONBLOCK)
3913+
req->flags |= REQ_F_NOWAIT;
3914+
39123915
ret = __sys_accept4_file(req->file, file_flags, accept->addr,
39133916
accept->addr_len, accept->flags,
39143917
accept->nofile);

0 commit comments

Comments
 (0)