diff mbox series

[4/5] socket: use IOCB_NOWAIT instead of O_NONBLOCK

Message ID 20190511165727.31599-4-source@stbuehler.de (mailing list archive)
State RFC
Headers show
Series [1/5] fs: RWF flags override default IOCB flags from file flags | expand

Commit Message

Stefan Bühler May 11, 2019, 4:57 p.m. UTC
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(-)
diff mbox series

Patch

diff --git a/net/socket.c b/net/socket.c
index 8255f5bda0aa..1e2f6819ea2b 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -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)