@@ -410,6 +410,7 @@ struct file *sock_alloc_file(struct socket *sock, int flags, const char *dname)
sock_release(sock);
return file;
}
+ file->f_mode |= FMODE_NOWAIT;
sock->file = file;
file->private_data = sock;
@@ -954,7 +955,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 (iocb->ki_flags & IOCB_NOWAIT)
msg.msg_flags = MSG_DONTWAIT;
if (iocb->ki_pos != 0)
@@ -979,7 +980,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 (iocb->ki_flags & IOCB_NOWAIT)
msg.msg_flags = MSG_DONTWAIT;
if (sock->type == SOCK_SEQPACKET)
Fix socket read_iter/write_iter implementations to handle IOCB_NOWAIT; for simple reads IOCB_NOWAIT will be set if O_NONBLOCK was set. Signed-off-by: Stefan Bühler <source@stbuehler.de> --- net/socket.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)