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

Hua Zhong (hzhong@cisco.com)
Wed, 4 Jun 2003 13:09:16 -0700


There is a missing piece in the previous mail. The complete patch is as
follows. I just googled it and the author is Sapan Bhatia .Cc-ed.

diff -urN linux-old/drivers/char/CVS/Entries linux/drivers/char/CVS/Entries
--- linux-old/drivers/char/CVS/Entries 2003-06-04 12:57:32.000000000 -0700
+++ linux/drivers/char/CVS/Entries 2003-06-04 13:01:35.000000000 -0700
@@ -194,5 +194,5 @@
D/pcmcia////
D/rio////
/tty_io.c/1.3/Wed Jun 4 19:28:08 2003//
-/pty.c/1.1/Wed Jun 4 19:57:20 2003//T1.1
-/n_tty.c/1.1/Wed Jun 4 19:57:32 2003//T1.1
+/n_tty.c/1.2/Wed Jun 4 20:01:32 2003//
+/pty.c/1.2/Wed Jun 4 20:01:32 2003//
diff -urN linux-old/drivers/char/n_tty.c linux/drivers/char/n_tty.c
--- linux-old/drivers/char/n_tty.c 2003-06-04 13:00:51.000000000 -0700
+++ linux/drivers/char/n_tty.c 2003-06-04 13:01:32.000000000 -0700
@@ -711,6 +711,23 @@
return 0;
}

+
+/*
+ * Required for the ptys, serial driver etc. since processes
+ * that attach themselves to the master and rely on ASYNC
+ * IO must be woken up
+ */
+
+static void n_tty_write_wakeup(struct tty_struct *tty)
+{
+ if (tty->fasync)
+ {
+ set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
+ kill_fasync(&tty->fasync, SIGIO, POLL_OUT);
+ }
+ return;
+}
+
static void n_tty_receive_buf(struct tty_struct *tty, const unsigned char
*cp,
char *fp, int count)
{
@@ -1157,6 +1174,8 @@
while (nr > 0) {
ssize_t num = opost_block(tty, b, nr);
if (num < 0) {
+ if (num == -EAGAIN)
+ break;
retval = num;
goto break_out;
}
@@ -1236,6 +1255,6 @@
normal_poll, /* poll */
n_tty_receive_buf, /* receive_buf */
n_tty_receive_room, /* receive_room */
- 0 /* write_wakeup */
+ n_tty_write_wakeup /* write_wakeup */
};

diff -urN linux-old/drivers/char/pty.c linux/drivers/char/pty.c
--- linux-old/drivers/char/pty.c 2003-06-04 13:01:04.000000000 -0700
+++ linux/drivers/char/pty.c 2003-06-04 13:01:32.000000000 -0700
@@ -331,6 +331,7 @@
clear_bit(TTY_OTHER_CLOSED, &tty->link->flags);
wake_up_interruptible(&pty->open_wait);
set_bit(TTY_THROTTLED, &tty->flags);
+ set_bit(TTY_DO_WRITE_WAKEUP, &tty->flags);
/* Register a slave for the master */
if (tty->driver.major == PTY_MASTER_MAJOR)
tty_register_devfs(&tty->link->driver,
à@

-
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/