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

From: Hua Zhong (hzhong@cisco.com)
Date: Wed Jun 04 2003 - 14:36:08 EST


> Do y ou have that other patch handy? It sounds like that is
> the real cause of the problem, and the patch quoted originally
> in this thread was a (broken) work-around..
>
> Linus
>

Something like this:

--- n_tty.c.old 2003-06-04 12:28:36.000000000 -0700
+++ n_tty.c 2003-06-04 12:28:51.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 */
 };
 
-
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:24 EST