Message ID | 4AC2E481.5060509@gmail.com |
---|---|
State | Superseded, archived |
Delegated to: | David Miller |
Headers | show |
> One way to handle this is to switch tcp_read() to use the underlying file O_NONBLOCK > flag, as other socket operations do. And let SPLICE_F_NONBLOCK control the pipe output only. Thanks Eric, this seems reasonable from my userspace perspective. I admit I don't understand why SPLICE_F_NONBLOCK exists, it seems very un-unixy to have a syscall completely ignore the NONBLOCK flag of the fd it is called on. Ie setting NONBLOCK on the pipe itself does nothing when using splice.. Jason -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jason Gunthorpe a écrit : >> One way to handle this is to switch tcp_read() to use the underlying file O_NONBLOCK >> flag, as other socket operations do. And let SPLICE_F_NONBLOCK control the pipe output only. arg, this was tcp_splice_read() of course > > Thanks Eric, this seems reasonable from my userspace perspective. > > I admit I don't understand why SPLICE_F_NONBLOCK exists, it seems very > un-unixy to have a syscall completely ignore the NONBLOCK flag of the > fd it is called on. Ie setting NONBLOCK on the pipe itself does > nothing when using splice.. > Hmm, good question, I dont have the answer but I'll digg one. -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Eric Dumazet a écrit : > Jason Gunthorpe a écrit : >>> One way to handle this is to switch tcp_read() to use the underlying file O_NONBLOCK >>> flag, as other socket operations do. And let SPLICE_F_NONBLOCK control the pipe output only. > > arg, this was tcp_splice_read() of course > >> Thanks Eric, this seems reasonable from my userspace perspective. >> >> I admit I don't understand why SPLICE_F_NONBLOCK exists, it seems very >> un-unixy to have a syscall completely ignore the NONBLOCK flag of the >> fd it is called on. Ie setting NONBLOCK on the pipe itself does >> nothing when using splice.. >> > > Hmm, good question, I dont have the answer but I'll digg one. > commit 29e350944fdc2dfca102500790d8ad6d6ff4f69d splice: add SPLICE_F_NONBLOCK flag It doesn't make the splice itself necessarily nonblocking (because the actual file descriptors that are spliced from/to may block unless they have the O_NONBLOCK flag set), but it makes the splice pipe operations nonblocking. Signed-off-by: Linus Torvalds <torvalds@osdl.org> See Linus intention was pretty clear : O_NONBLOCK should be taken into account by 'actual file that are spliced from/to', regardless of SPLICE_F_NONBLOCK flag -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
On Wed, Sep 30, 2009 at 08:00:04AM +0200, Eric Dumazet wrote: > >> I admit I don't understand why SPLICE_F_NONBLOCK exists, it seems very > >> un-unixy to have a syscall completely ignore the NONBLOCK flag of the > >> fd it is called on. Ie setting NONBLOCK on the pipe itself does > >> nothing when using splice.. > > > > Hmm, good question, I dont have the answer but I'll digg one. > > > > commit 29e350944fdc2dfca102500790d8ad6d6ff4f69d > splice: add SPLICE_F_NONBLOCK flag > > It doesn't make the splice itself necessarily nonblocking (because the > actual file descriptors that are spliced from/to may block unless they > have the O_NONBLOCK flag set), but it makes the splice pipe operations > nonblocking. > > Signed-off-by: Linus Torvalds <torvalds@osdl.org> > > See Linus intention was pretty clear : O_NONBLOCK should be taken > into account by 'actual file that are spliced from/to', regardless > of SPLICE_F_NONBLOCK flag Yes, that seems reasonable. What confuses me is that if O_NONBLOCK is set on the _pipe_ and SPICE_F_NONBLOCK is not set on the splice call the splice still blocks - that is unlike other unix apis, eg MSG_DONTWAIT It seems to me that SPICE_F_NONBLOCK should be or'd with O_NONBLOCK on the pipe? Thanks, Jason -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 21387eb..8cdfab6 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -580,7 +580,7 @@ ssize_t tcp_splice_read(struct socket *sock, loff_t *ppos, lock_sock(sk); - timeo = sock_rcvtimeo(sk, flags & SPLICE_F_NONBLOCK); + timeo = sock_rcvtimeo(sk, sock->file->f_flags & O_NONBLOCK); while (tss.len) { ret = __tcp_splice_read(sk, &tss); if (ret < 0)