From: Peter Benie <peterb@chiark.greenend.org.uk>
To: Alan.Cox@linux.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] [2.2] pipe_write can block even with non-blocking fd
Date: Sat, 7 Dec 2002 20:55:50 +0000 (GMT) [thread overview]
Message-ID: <15858.24662.553969.380236@server.axiom.internal> (raw)
Please apply the following patch. This makes non-blocking writes to
pipe actually non-blocking.
A program that demonstrates the bug can be found at:
http://www.chiark.greenend.org.uk/~peterb/linux/nonblock/pipe-testnonblock.c
--- 2.2.19/fs/pipe.c.orig Thu Dec 6 21:20:38 2001
+++ 2.2.19/fs/pipe.c Thu Dec 6 21:22:47 2001
@@ -105,9 +105,17 @@
else
free = 1; /* can't do it atomically, wait for any free space */
up(&inode->i_sem);
- if (down_interruptible(&inode->i_atomic_write)) {
- down(&inode->i_sem);
- return -ERESTARTSYS;
+ if (filp->f_flags & O_NONBLOCK) {
+ if (down_trylock(&inode->i_atomic_write)) {
+ down(&inode->i_sem);
+ return -ERESTARTSYS;
+ }
+ }
+ else {
+ if (down_interruptible(&inode->i_atomic_write)) {
+ down(&inode->i_sem);
+ return -ERESTARTSYS;
+ }
}
while (count>0) {
while ((PIPE_FREE(*inode) < free) || PIPE_LOCK(*inode)) {
reply other threads:[~2002-12-07 20:48 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=15858.24662.553969.380236@server.axiom.internal \
--to=peterb@chiark.greenend.org.uk \
--cc=Alan.Cox@linux.org \
--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®