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

login
register
mail settings
Submitter Chris J Arges
Date Oct. 10, 2013, 1:37 p.m.
Message ID <1381412234-24899-2-git-send-email-chris.j.arges@canonical.com>
Download mbox | patch
Permalink /patch/282260/
State New
Headers show

Comments

Chris J Arges - Oct. 10, 2013, 1:37 p.m.
From: Maximiliano Curia <maxy@gnuservers.com.ar>

upstreamed

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(-)
Tim Gardner - Oct. 10, 2013, 2:21 p.m.

Steve Conklin - Oct. 10, 2013, 2:26 p.m.
On 10/10/2013 08:37 AM, Chris J Arges wrote:
> From: Maximiliano Curia <maxy@gnuservers.com.ar>
> 
> upstreamed
> 
> 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(-)
> 
> diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
> index 72d3ff8..98705aa 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 = tty->icanon && !tty->canon_data;
> +		} else {
> +			left = 0;
> +		}
> +
>  	old_left = tty->receive_room;
>  	tty->receive_room = left;
>  
>

Patch

diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
index 72d3ff8..98705aa 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 = tty->icanon && !tty->canon_data;
+		} else {
+			left = 0;
+		}
+
 	old_left = tty->receive_room;
 	tty->receive_room = left;