patch-2.0.31 linux/drivers/char/pty.c
Next file: linux/drivers/char/random.c
Previous file: linux/drivers/char/pcwd.c
Back to the patch index
Back to the overall index
- Lines: 34
- Date:
Thu Aug 7 09:34:37 1997
- Orig file:
v2.0.30/linux/drivers/char/pty.c
- Orig date:
Mon Sep 30 06:56:48 1996
diff -u --recursive --new-file v2.0.30/linux/drivers/char/pty.c linux/drivers/char/pty.c
@@ -153,14 +153,32 @@
return to->ldisc.receive_room(to);
}
+/*
+ * Modified for asymmetric master/slave behavior
+ * The chars_in_buffer() value is used by the ldisc select() function
+ * to hold off writing when chars_in_buffer > WAKEUP_CHARS (== 256).
+ * To allow typed-ahead commands to accumulate, the master side returns 0
+ * until the buffer is half full. The slave side returns the true count.
+ */
static int pty_chars_in_buffer(struct tty_struct *tty)
{
struct tty_struct *to = tty->link;
+ int count;
if (!to || !to->ldisc.chars_in_buffer)
return 0;
- return to->ldisc.chars_in_buffer(to);
+ /* The ldisc must report 0 if no characters available to be read */
+ count = to->ldisc.chars_in_buffer(to);
+
+ if (tty->driver.subtype == PTY_TYPE_SLAVE) return count;
+
+ /*
+ * Master side driver ... return 0 if the other side's read buffer
+ * is less than half full. This allows room for typed-ahead commands
+ * with a reasonable margin to avoid overflow.
+ */
+ return ((count < N_TTY_BUF_SIZE/2) ? 0 : count);
}
static void pty_flush_buffer(struct tty_struct *tty)
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov