[PATCH 2/5] tcp: handle SPLICE_F_NONBLOCK in tcp_splice_read

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Now both O_NONBLOCK and SPLICE_F_NONBLOCK will trigger non-blocking
behavior.

The spice man page is unclear about the exact semantics:

First it says splice may still block if SPLICE_F_NONBLOCK is set but
O_NONBLOCK isn't.

Then it says it might return EAGAIN if one or the other is set (and on
my debian system it says EAGAIN can only be returned if
SPLICE_F_NONBLOCK was set).

Signed-off-by: Stefan Bühler <source@xxxxxxxxxxxx>
---
 net/ipv4/tcp.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index 6baa6dc1b13b..65f9917ed8ca 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -784,6 +784,8 @@ ssize_t tcp_splice_read(struct socket *sock, loff_t *ppos,
 	long timeo;
 	ssize_t spliced;
 	int ret;
+	bool noblock = (sock->file->f_flags & O_NONBLOCK) ||
+		       (flags & SPLICE_F_NONBLOCK);
 
 	sock_rps_record_flow(sk);
 	/*
@@ -796,7 +798,7 @@ ssize_t tcp_splice_read(struct socket *sock, loff_t *ppos,
 
 	lock_sock(sk);
 
-	timeo = sock_rcvtimeo(sk, sock->file->f_flags & O_NONBLOCK);
+	timeo = sock_rcvtimeo(sk, noblock);
 	while (tss.len) {
 		ret = __tcp_splice_read(sk, &tss);
 		if (ret < 0)
-- 
2.20.1




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux