diff options
| author | Jens Axboe <axboe@kernel.dk> | 2019-12-09 20:58:56 -0700 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-01-09 10:18:57 +0100 |
| commit | b280f0ea1c8332a1dc10542064d2f2e934ccf7e0 (patch) | |
| tree | 3514c3cca8e36a4ea67d08946f76ea79884d7c77 /net | |
| parent | 9d5b54cfe0afe4e5de2f27dc6213a49a509f4e2a (diff) | |
net: make socket read/write_iter() honor IOCB_NOWAIT
[ Upstream commit ebfcd8955c0b52eb793bcbc9e71140e3d0cdb228 ]
The socket read/write helpers only look at the file O_NONBLOCK. not
the iocb IOCB_NOWAIT flag. This breaks users like preadv2/pwritev2
and io_uring that rely on not having the file itself marked nonblocking,
but rather the iocb itself.
Cc: netdev@vger.kernel.org
Acked-by: David Miller <davem@davemloft.net>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'net')
| -rw-r--r-- | net/socket.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/net/socket.c b/net/socket.c index 18d27b8c2511..1290aad5d1c3 100644 --- a/net/socket.c +++ b/net/socket.c @@ -867,7 +867,7 @@ static ssize_t sock_read_iter(struct kiocb *iocb, struct iov_iter *to) .msg_iocb = iocb}; ssize_t res; - if (file->f_flags & O_NONBLOCK) + if (file->f_flags & O_NONBLOCK || (iocb->ki_flags & IOCB_NOWAIT)) msg.msg_flags = MSG_DONTWAIT; if (iocb->ki_pos != 0) @@ -892,7 +892,7 @@ static ssize_t sock_write_iter(struct kiocb *iocb, struct iov_iter *from) if (iocb->ki_pos != 0) return -ESPIPE; - if (file->f_flags & O_NONBLOCK) + if (file->f_flags & O_NONBLOCK || (iocb->ki_flags & IOCB_NOWAIT)) msg.msg_flags = MSG_DONTWAIT; if (sock->type == SOCK_SEQPACKET) |
