mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: David H?rdeman <david@hardeman.nu>
Cc: linux-kernel@vger.kernel.org
Subject: Re: splice question
Date: Sun, 12 Aug 2007 12:41:54 -0700 (PDT)	[thread overview]
Message-ID: <alpine.LFD.0.999.0708121238390.30176@woody.linux-foundation.org> (raw)
In-Reply-To: <20070812162820.GA26892@hardeman.nu>



On Sun, 12 Aug 2007, David H?rdeman wrote:
> 
> Once the data is in the pipe, my idea was to tee() from the pipe to each
> client socket using nonblocking ops, and then consume the data by splicing it
> to /dev/null.
> 
> The problem is that tee() doesn't support sockets. Is this a limitation that
> would be easy to fix?

It's very intentional. 

You should think of "tee()" as a memcpy() on kernel buffers.

And what are kernel buffers? It's not a socket.

The "kernel buffer" is simply just another name for a pipe.

So tee() *duplicates* the data in pipe, and then you can use "splice()" on 
the duplicated data to actually send it off somewhere else (eg a socket).

(Or any other pipe operation, for that matter - you can read() it into 
user space etc).

> Otherwise I guess I'd have to add a second pipe, then (in a loop)
> tee() from the first to the second pipe and then splice from the second pipe
> to a socket. Doesn't sound very elegant and would need quite a lot of extra
> syscalls.

You really should think of this as a memcpy(), and you'll be in the right 
mindframe. The system calls themselves are cheap.

			Linus

  reply	other threads:[~2007-08-12 19:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-12 16:28 David Härdeman
2007-08-12 19:41 ` Linus Torvalds [this message]
2007-08-12 20:56   ` David Härdeman

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=alpine.LFD.0.999.0708121238390.30176@woody.linux-foundation.org \
    --to=torvalds@linux-foundation.org \
    --cc=david@hardeman.nu \
    --cc=linux-kernel@vger.kernel.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

all inboxes | Powered by JetHome®