From: Eric Dumazet <eric.dumazet@gmail.com>
To: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
Cc: Volker Lendecke <Volker.Lendecke@SerNet.DE>,
netdev@vger.kernel.org, Volker Lendecke <vl@samba.org>
Subject: Re: Splice on blocking TCP sockets again..
Date: Fri, 02 Oct 2009 20:05:01 +0200 [thread overview]
Message-ID: <4AC640CD.2030204@gmail.com> (raw)
In-Reply-To: <20091002171029.GG5191@obsidianresearch.com>
Jason Gunthorpe a écrit :
>
> I'd suggest a construct like the following as a compatability
> solution:
>
> struct pollfd pfd = {.fd = tcpfd, events = POLLIN | POLLRDHUP};
> while (..) {
> rc = splice(tcpfd,0,pfd[1],0,count,SPLICE_F_MOVE | SPLICE_F_NONBLOCK);
> if (rc == -1)
> //...
> if (rc == 0) {
> if (pfd.revents & POLLRDHUP)
> // oops, EOF on TCP
>
> /* Might be an old kernel that nonblocks on TCP, have to check
> if this is EOF or do blocking. */
> rc = poll(&pfd,1,-1);
> if (rc == -1)
> //...
> }
>
> rc = splice(pfd[0],0,ofd,0,..., SPLICE_F_MOVE)
> }
>
> Which should add no overhead in the new splice blocks case, and falls
> back gracefully on older kernels..
>
Agreed, thanks for the tip.
Indeed, new kernel will permit a loop with only splice() syscalls, while on an old
kernel, some poll() syscalls might be needed if tcp socket is empty.
prev parent reply other threads:[~2009-10-02 18:05 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-30 0:48 Splice on blocking TCP sockets again Jason Gunthorpe
2009-09-30 4:54 ` Eric Dumazet
2009-09-30 5:40 ` Jason Gunthorpe
2009-09-30 5:51 ` Eric Dumazet
2009-09-30 6:00 ` Eric Dumazet
2009-09-30 6:19 ` Eric Dumazet
2009-10-01 22:17 ` Jason Gunthorpe
2009-09-30 6:37 ` Volker Lendecke
2009-10-02 17:10 ` Jason Gunthorpe
2009-10-02 18:05 ` Eric Dumazet [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4AC640CD.2030204@gmail.com \
--to=eric.dumazet@gmail.com \
--cc=Volker.Lendecke@SerNet.DE \
--cc=jgunthorpe@obsidianresearch.com \
--cc=netdev@vger.kernel.org \
--cc=vl@samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).