]> git.pld-linux.org Git - packages/kernel.git/blob - kernel-large-readline-paste.patch
- 3.1.101
[packages/kernel.git] / kernel-large-readline-paste.patch
1 ¡Hola Peter!
2
3 El 2013-08-19 a las 08:25 -0400, Peter Hurley escribió:
4 > My primary concern is canonical readers not become stuck with a full
5 > read buffer, even with bogus input data (IOW, that an error condition will
6 > not prevent a reader from making forward progress). I believe that won't
7 > happen with this change, but what I really need in this case is a detailed
8 > analysis from you of why that won't happen. That analysis should be in
9 > the patch changelog. (Feel free to send me private mail if you need help
10 > preparing a patch.)
11
12 I'm not sure what level of analysis you are looking for. The driver will block
13 when there are no readers but as soon as there is a read call it unblocks.
14 I've added this information to the patch description that I'm including below.
15
16 > And the patch above has a bug that allows a negative 'left' to be
17 > assigned to tty->receive_room which will be interpreted as a very large
18 > positive value.
19
20 Ok, fixed with an else clause. It could also use an extra &&, but it looks a
21 bit confusing.
22
23 > This approach still has several drawbacks.
24
25 > 1) Since additional state is reset when the termios is changed by
26 > readline(), the canonical line buffer state will be bogus.
27 > This renders the termios change by readline() pointless; the
28 > caller will not be able to retrieve expected input properly.
29
30 > 2) Since the input data is interpreted with the current termios when
31 > data is received, any embedded control characters will not be
32 > interpreted properly; again, the caller will not be able to retrieve
33 > expected input properly.
34
35 Indeed this is correct, however this is not an issue of this patch but of the
36 current interaction between the kernel and readline. In order to fix this, the
37 reading buffer should always be in raw and only when responding to a read call
38 for canonical mode should it be interpreted. This is a very big change, and
39 I'm not sure if anybody will be interested in implementing it.
40
41 > >What do you think? Is the proposed solution, or something along those lines,
42 > >acceptable?
43
44 > I'm wondering if this problem might be best addressed on the paste side
45 > instead of the read side. Although this wouldn't be a magic bullet, it
46 > would be easier to control when more paste data is added.
47
48 I don't see how this could work, could you elaborate?
49
50 This is the patch proposal, for comments:
51
52 From 81afd3b666cbf94bb9923ebf87fb2017a7cd645e Mon Sep 17 00:00:00 2001
53 From: Maximiliano Curia <maxy@gnuservers.com.ar>
54 Date: Tue, 3 Sep 2013 22:48:34 +0200
55 Subject: [PATCH] Only let characters through when there are active readers.
56
57 If there is an active reader, previous behavior is in place. When there is no
58 active reader, input is blocked until the next read call unblocks it.
59
60 This fixes a long standing issue with readline when pasting more than 4096
61 bytes.
62 ---
63  drivers/tty/n_tty.c | 9 ++++++++-
64  1 file changed, 8 insertions(+), 1 deletion(-)
65
66 diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
67 index 4bf0fc0..cdc3b19 100644
68 --- a/drivers/tty/n_tty.c
69 +++ b/drivers/tty/n_tty.c
70 @@ -147,9 +147,16 @@ static int set_room(struct tty_struct *tty)
71          * pending newlines, let characters through without limit, so
72          * that erase characters will be handled.  Other excess
73          * characters will be beeped.
74 +        * If there is no reader waiting for the input, block instead of
75 +        * letting the characters through.
76          */
77         if (left <= 0)
78 -               left = ldata->icanon && !ldata->canon_data;
79 +               if (waitqueue_active(&tty->read_wait)) {
80 +                       left = ldata->icanon && !ldata->canon_data;
81 +               } else {
82 +                       left = 0;
83 +               }
84 +
85         old_left = tty->receive_room;
86         tty->receive_room = left;
87  
88 -- 
89 1.8.4.rc3
90
91
92 -- 
93 "Always code as if the person who ends up maintaining your code is a violent
94 psychopath who knows where you live."
95 -- John Woods
96 Saludos /\/\ /\ >< `/
This page took 0.064732 seconds and 3 git commands to generate.