mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Max Kellermann <max@duempel.org>
To: "Américo Wang" <xiyou.wangcong@gmail.com>
Cc: linux-kernel@vger.kernel.org, eric.dumazet@gmail.com
Subject: Re: [PATCH] pipe: don't block after data has been written
Date: Thu, 5 Nov 2009 17:25:54 +0100	[thread overview]
Message-ID: <20091105162554.GA5430@squirrel.roonstrasse.net> (raw)
In-Reply-To: <20091105162043.GA2611@hack>

On 2009/11/05 17:20, Américo Wang <xiyou.wangcong@gmail.com> wrote:
> On Thu, Nov 05, 2009 at 04:31:47PM +0100, Max Kellermann wrote:
> >According to the select() / poll() documentation, a write operation on
> >a file descriptor which is "ready for writing" must not block.  Linux
> >violates this rule: if you pass a very large buffer to write(), the
> >system call will not return until everything is written, or an error
> >occurs.
> >
> >This patch adds a simple check: if at least one byte has already been
> >written, break from the loop, instead of calling pipe_wait().
> 
> Do you have any working test-case for this?

Eric Dumazet posted a program earlier today (in response to my
pipe/splice patch):

 http://lkml.org/lkml/2009/11/5/144

With this patch applied, it runs correctly (without it, the write()
blocks until the consumer has read everything):

 poll([{fd=4, events=POLLOUT}], 1, -1)   = 1 ([{fd=4, revents=POLLOUT}])
 [...]
 write(4, "\0\0\0\0"..., 1000000) = 65536

  reply	other threads:[~2009-11-05 16:25 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-05 15:31 Max Kellermann
2009-11-05 16:20 ` Américo Wang
2009-11-05 16:25   ` Max Kellermann [this message]
2009-11-05 16:27 ` Eric Dumazet
2009-11-05 16:36   ` Max Kellermann
2009-11-05 16:37     ` Eric Dumazet
2009-11-05 17:13       ` Zan Lynx
2009-11-05 18:32         ` Alan Cox

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=20091105162554.GA5430@squirrel.roonstrasse.net \
    --to=max@duempel.org \
    --cc=eric.dumazet@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=xiyou.wangcong@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

all inboxes | Powered by JetHome®