[PATCH] [2.5] Non-blocking write can block

From: P. Benie (pjb1008@eng.cam.ac.uk)
Date: Tue Jun 03 2003 - 19:58:02 EST


Non-blocking writes to a tty will block if there is a blocking write
waiting for the atomic_write semaphore.

Peter

--- linux-2.5.70/drivers/char/tty_io.c.orig 2003-06-03 21:34:42.000000000 +0100
+++ linux-2.5.70/drivers/char/tty_io.c 2003-06-04 01:40:33.000000000 +0100
@@ -687,8 +687,13 @@
 {
         ssize_t ret = 0, written = 0;

- if (down_interruptible(&tty->atomic_write)) {
- return -ERESTARTSYS;
+ if (file->f_flags & O_NONBLOCK) {
+ if (down_trylock(&tty->atomic_write))
+ return -EAGAIN;
+ }
+ else {
+ if (down_interruptible(&tty->atomic_write))
+ return -ERESTARTSYS;
         }
         if ( test_bit(TTY_NO_WRITE_SPLIT, &tty->flags) ) {
                 lock_kernel();

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sat Jun 07 2003 - 22:00:22 EST