mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Amerigo Wang <xiyou.wangcong@gmail.com>
To: Changli Gao <xiaosuo@gmail.com>
Cc: Amerigo Wang <xiyou.wangcong@gmail.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: PROPOSAL: extend pipe() to support NULL argument.
Date: Fri, 3 Jul 2009 15:15:04 +0800	[thread overview]
Message-ID: <20090703071504.GG5880@cr0.nay.redhat.com> (raw)
In-Reply-To: <412e6f7f0907022242r52ad981fyd51c2a55f41ab228@mail.gmail.com>

On Fri, Jul 03, 2009 at 01:42:12PM +0800, Changli Gao wrote:
>On Fri, Jul 3, 2009 at 1:19 PM, Amerigo Wang<xiyou.wangcong@gmail.com> wrote:
>>
>>
>> Yes, exactly.
>> Inventing a new API is better than modifying pipe(2), IMO.
>>
>> BUT I still don't agree that you really need this... I think you
>> can add a flag or something like that to an fd to do this, e.g.
>>
>>   fcntl(fd, F_SETFD, FD_PIPERW);
>>
>> Isn't this better?
>You don't understand my need. I don't want to change a RDONLY or
>WRONLY pipe to a RW one, but I want to pipe() return just one RW pipe
>instead.

This is exacly what I meant by that example.

>It seems you prefer pipe0() to pipe(NULL).

pipefd() seems better.

>>>You don't know my meaning. As a proxy server, there maybe lots of
>>>connections to maintain, and these connections will keep open for a
>>>long time. If the data received can be sent in a relay cycle, the
>>>kernel buffer can be reused. If not, the kernel buffer must be
>>>reserved. When there are lots of these kinds of connections, lots of
>>>kernel buffers must be reserved. At this time, whether two fds per
>>>kernel buffer or one fds per kernel buffer matters.
>>
>> SHow us the code, please.
>>
>If you don't know my need after reading my words, I don't think you
>can understand the fake code.

No, code is *much* better than any of your words.

>The fake code:
>
>main thread:
>
>while (1) {
>   fd = accept();
>   pthread_create(worker, fd);
>}
>
>worker thread(assume data is transfered just from client to server for
>simplification):
>
>serv_fd = connect();
>while (1) {
>  select(fd, RD);
>  pipe = get_pipe_from_poll();
>  n = splice(fd, pipe);
>  while (n > 0) {
>     n -= splice(pipe, serv_fd);
>  }
>  put_pipe_to_poll();
>}
>close(serv_fd);
>close(fd);

If saving one fd really helps here, probably you want to
save more, you will need a syscall like:

  int splice_without_new_fd(int infd, int outfd);

But splice(2) is designed to be as it is. You need to increase
your fd limit, instead of saving one by pipe().

  reply	other threads:[~2009-07-03  7:13 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-02  7:36 Changli Gao
2009-07-02  9:13 ` Amerigo Wang
2009-07-02  9:18   ` Changli Gao
2009-07-02  9:46     ` Amerigo Wang
2009-07-02 10:04       ` Changli Gao
2009-07-02 10:21         ` Amerigo Wang
2009-07-03  0:43           ` Changli Gao
2009-07-03  1:55             ` Amerigo Wang
2009-07-03  2:10               ` Changli Gao
2009-07-03  3:00                 ` Amerigo Wang
2009-07-03  4:08                   ` Changli Gao
2009-07-03  5:19                     ` Amerigo Wang
2009-07-03  5:42                       ` Changli Gao
2009-07-03  7:15                         ` Amerigo Wang [this message]
2009-07-03  7:40                           ` Changli Gao
2009-07-03  8:16                             ` Amerigo Wang
2009-07-03  8:27                               ` Changli Gao
2009-07-03  9:42                                 ` Amerigo Wang
2009-07-03  9:59                                   ` Changli Gao
2009-07-03 10:23                                     ` Amerigo Wang
2009-07-03 10:28                                     ` Albert ARIBAUD
2009-07-06  1:12                                       ` Changli Gao
2009-07-06  6:15                                         ` Albert ARIBAUD
2009-07-06  6:23                                           ` Changli Gao
2009-07-06  6:30                                             ` Albert ARIBAUD
2009-07-07  4:43                                       ` Denys Vlasenko
2009-07-07  7:45                                         ` Changli Gao
2009-07-07 20:37                                           ` David Newall
2009-07-07 21:02                                             ` Zan Lynx
2009-07-08  4:41                                               ` Changli Gao
2009-07-08  4:43                                                 ` David Newall
2009-07-02 10:42     ` Alan Cox
2009-07-03  0:45       ` Changli Gao

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=20090703071504.GG5880@cr0.nay.redhat.com \
    --to=xiyou.wangcong@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=xiaosuo@gmail.com \
    /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

Powered by JetHome