Re: [PATCH] pipe: don't block after data has been written

From: Max Kellermann
Date: Thu Nov 05 2009 - 11:26:01 EST

On 2009/11/05 17:20, Américo Wang <xiyou.wangcong@xxxxxxxxx> 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):

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
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at