@@ -28,6 +28,7 @@ struct io_accept {
28
28
struct sockaddr __user * addr ;
29
29
int __user * addr_len ;
30
30
int flags ;
31
+ int iou_flags ;
31
32
u32 file_slot ;
32
33
unsigned long nofile ;
33
34
};
@@ -1489,7 +1490,6 @@ void io_sendrecv_fail(struct io_kiocb *req)
1489
1490
int io_accept_prep (struct io_kiocb * req , const struct io_uring_sqe * sqe )
1490
1491
{
1491
1492
struct io_accept * accept = io_kiocb_to_cmd (req , struct io_accept );
1492
- unsigned flags ;
1493
1493
1494
1494
if (sqe -> len || sqe -> buf_index )
1495
1495
return - EINVAL ;
@@ -1498,24 +1498,26 @@ int io_accept_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
1498
1498
accept -> addr_len = u64_to_user_ptr (READ_ONCE (sqe -> addr2 ));
1499
1499
accept -> flags = READ_ONCE (sqe -> accept_flags );
1500
1500
accept -> nofile = rlimit (RLIMIT_NOFILE );
1501
- flags = READ_ONCE (sqe -> ioprio );
1502
- if (flags & ~IORING_ACCEPT_MULTISHOT )
1501
+ accept -> iou_flags = READ_ONCE (sqe -> ioprio );
1502
+ if (accept -> iou_flags & ~( IORING_ACCEPT_MULTISHOT | IORING_ACCEPT_DONTWAIT ) )
1503
1503
return - EINVAL ;
1504
1504
1505
1505
accept -> file_slot = READ_ONCE (sqe -> file_index );
1506
1506
if (accept -> file_slot ) {
1507
1507
if (accept -> flags & SOCK_CLOEXEC )
1508
1508
return - EINVAL ;
1509
- if (flags & IORING_ACCEPT_MULTISHOT &&
1509
+ if (accept -> iou_flags & IORING_ACCEPT_MULTISHOT &&
1510
1510
accept -> file_slot != IORING_FILE_INDEX_ALLOC )
1511
1511
return - EINVAL ;
1512
1512
}
1513
1513
if (accept -> flags & ~(SOCK_CLOEXEC | SOCK_NONBLOCK ))
1514
1514
return - EINVAL ;
1515
1515
if (SOCK_NONBLOCK != O_NONBLOCK && (accept -> flags & SOCK_NONBLOCK ))
1516
1516
accept -> flags = (accept -> flags & ~SOCK_NONBLOCK ) | O_NONBLOCK ;
1517
- if (flags & IORING_ACCEPT_MULTISHOT )
1517
+ if (accept -> iou_flags & IORING_ACCEPT_MULTISHOT )
1518
1518
req -> flags |= REQ_F_APOLL_MULTISHOT ;
1519
+ if (accept -> iou_flags & IORING_ACCEPT_DONTWAIT )
1520
+ req -> flags |= REQ_F_NOWAIT ;
1519
1521
return 0 ;
1520
1522
}
1521
1523
@@ -1540,7 +1542,8 @@ int io_accept(struct io_kiocb *req, unsigned int issue_flags)
1540
1542
if (!fixed )
1541
1543
put_unused_fd (fd );
1542
1544
ret = PTR_ERR (file );
1543
- if (ret == - EAGAIN && force_nonblock ) {
1545
+ if (ret == - EAGAIN && force_nonblock &&
1546
+ !(accept -> iou_flags & IORING_ACCEPT_DONTWAIT )) {
1544
1547
/*
1545
1548
* if it's multishot and polled, we don't need to
1546
1549
* return EAGAIN to arm the poll infra since it
0 commit comments