diff mbox

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

Message ID 1381412234-24899-2-git-send-email-chris.j.arges@canonical.com
State New
Headers show

Commit Message

Chris J Arges Oct. 10, 2013, 1:37 p.m. UTC
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(-)

Comments

Tim Gardner Oct. 10, 2013, 2:21 p.m. UTC | #1

Steve Conklin Oct. 10, 2013, 2:26 p.m. UTC | #2
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;
>  
>
diff mbox

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;