* do_tty_write() can block even with O_NONBLOCK?
@ 2007-05-02 15:17 Dave Johnson
2007-05-02 16:02 ` Alan Cox
0 siblings, 1 reply; 2+ messages in thread
From: Dave Johnson @ 2007-05-02 15:17 UTC (permalink / raw)
To: linux-kernel
I have two processes with the same tty open, one opens blocking and
one opens nonblocking.
If the blocking process blocks doing a write (due to flow control,
just going to fast, etc...) the nonblocking process will also block
when it writes until the blocking process unblocks.
This seems to occur because do_tty_write() isn't checking for
O_NONBLOCK when taking the tty's write mutex.
Signed-off-by: Dave Johnson <djohnson+linux-kernel@sw.starentnetworks.com>
===== drivers/char/tty_io.c 1.237 vs edited =====
--- 1.237/drivers/char/tty_io.c 2007-03-18 16:40:06 -04:00
+++ edited/drivers/char/tty_io.c 2007-05-01 10:53:27 -04:00
@@ -1690,9 +1690,13 @@
ssize_t ret = 0, written = 0;
unsigned int chunk;
- /* FIXME: O_NDELAY ... */
- if (mutex_lock_interruptible(&tty->atomic_write_lock)) {
- return -ERESTARTSYS;
+ if (file->f_flags & O_NONBLOCK) {
+ if (!mutex_trylock(&tty->atomic_write_lock))
+ return -EAGAIN;
+ }
+ else {
+ if (mutex_lock_interruptible(&tty->atomic_write_lock))
+ return -ERESTARTSYS;
}
/*
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: do_tty_write() can block even with O_NONBLOCK?
2007-05-02 15:17 do_tty_write() can block even with O_NONBLOCK? Dave Johnson
@ 2007-05-02 16:02 ` Alan Cox
0 siblings, 0 replies; 2+ messages in thread
From: Alan Cox @ 2007-05-02 16:02 UTC (permalink / raw)
To: Dave Johnson, akpm; +Cc: linux-kernel
On Wed, 2 May 2007 11:17:00 -0400
Dave Johnson <djohnson+linux-kernel@sw.starentnetworks.com> wrote:
>
> I have two processes with the same tty open, one opens blocking and
> one opens nonblocking.
>
> If the blocking process blocks doing a write (due to flow control,
> just going to fast, etc...) the nonblocking process will also block
> when it writes until the blocking process unblocks.
>
> This seems to occur because do_tty_write() isn't checking for
> O_NONBLOCK when taking the tty's write mutex.
>
>
> Signed-off-by: Dave Johnson <djohnson+linux-kernel@sw.starentnetworks.com>
Acked-by: Alan Cox <alan@redhat.com>
Looks fine to me.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-05-02 15:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-05-02 15:17 do_tty_write() can block even with O_NONBLOCK? Dave Johnson
2007-05-02 16:02 ` Alan Cox
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®