Patchwork SAUCE: (no-up) Only let characters through when there are active readers.

login
register
mail settings
Submitter Chris J Arges
Date Oct. 8, 2013, 5:28 p.m.
Message ID <1381253293-5209-2-git-send-email-chris.j.arges@canonical.com>
Download mbox | patch
Permalink /patch/281526/
State New
Headers show

Comments

Chris J Arges - Oct. 8, 2013, 5:28 p.m.
From: Maximiliano Curia <maxy@gnuservers.com.ar>

BugLink: http://bugs.launchpad.net/bugs/1208740

If there is an active reader, previous behavior is in place. When there is no
active reader, input is blocked until the next read call unblocks it.

This fixes a long standing issue with readline when pasting more than 4096
bytes.

Signed-off-by: Chris J Arges <chris.j.arges@canonical.com>
---
 drivers/tty/n_tty.c |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

Patch

diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
index 72d3ff8..367259e 100644
--- a/drivers/tty/n_tty.c
+++ b/drivers/tty/n_tty.c
@@ -101,9 +101,16 @@  static void n_tty_set_room(struct tty_struct *tty)
 	 * pending newlines, let characters through without limit, so
 	 * that erase characters will be handled.  Other excess
 	 * characters will be beeped.
+	 * If there is no reader waiting for the input, block instead of
+	 * letting the characters through.
 	 */
 	if (left <= 0)
-		left = tty->icanon && !tty->canon_data;
+		if (waitqueue_active(&tty->read_wait)) {
+			left = ldata->icanon && !ldata->canon_data;
+		} else {
+			left = 0;
+		}
+
 	old_left = tty->receive_room;
 	tty->receive_room = left;