All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pipe: don't block after data has been written
@ 2009-11-05 15:31 Max Kellermann
  2009-11-05 16:20 ` Américo Wang
  2009-11-05 16:27 ` Eric Dumazet
  0 siblings, 2 replies; 8+ messages in thread
From: Max Kellermann @ 2009-11-05 15:31 UTC (permalink / raw)
  To: linux-kernel; +Cc: eric.dumazet, mk

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().

Signed-off-by: Max Kellermann <max@duempel.org>
---

 fs/pipe.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/fs/pipe.c b/fs/pipe.c
index ae17d02..9d84f0b 100644
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@ -582,7 +582,7 @@ redo2:
 		}
 		if (bufs < PIPE_BUFFERS)
 			continue;
-		if (filp->f_flags & O_NONBLOCK) {
+		if (filp->f_flags & O_NONBLOCK || ret > 0) {
 			if (!ret)
 				ret = -EAGAIN;
 			break;


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2009-11-05 18:31 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-05 15:31 [PATCH] pipe: don't block after data has been written Max Kellermann
2009-11-05 16:20 ` Américo Wang
2009-11-05 16:25   ` Max Kellermann
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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.