mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 17:38:00 +00:00
lineedit_send_line: batch up output characters.
When the user pressed Return at the end of a line, we were calling the TermLineEditor's receiver function once for each character in the line buffer. A Telnet user reported from looking at packet traces that this leads to each character being sent in its own TCP segment, which is wasteful and silly, and a regression in 0.82 compared to 0.81. You can see the SSH version of the phenomenon even more easily in PuTTY's own SSH logs, without having to look at the TCP layer at all: you get a separate SSH2_MSG_CHANNEL_DATA per character when sending a line that you entered via local editing in the GUI terminal. The fix in this commit makes lineedit_send_line() collect keystrokes into a temporary bufchain and pass them on to the backend in chunks the size of a bufchain block. This is better, but still not completely ideal: lineedit_send_line() is often followed by a call to lineedit_send_newline(), and there's no buffering done between _those_ functions. So you'll still see a separate SSH message / Telnet TCP segment for the newline after the line. I haven't fixed that in this commit, for two reasons. First, unlike the character-by-character sending of the line content, it's not a regression in 0.82: previous versions also sent the newline in a separate packet and nobody complained about that. Second, it's much more difficult, because newlines are handled specially - in particular by the Telnet backend, which sometimes turns them into a wire sequence CR LF that can't be generated by passing any literal byte to backend_send. So you'd need to violate a load of layers, or else have multiple parts of the system buffer up output and then arrange to release it on a toplevel callback or some such. Much more code, more risk of bugs, and less gain.
This commit is contained in:
parent
edd5e13ffc
commit
1ce8ec9c82
@ -157,8 +157,19 @@ static void lineedit_delete_line(TermLineEditor *le)
|
|||||||
|
|
||||||
void lineedit_send_line(TermLineEditor *le)
|
void lineedit_send_line(TermLineEditor *le)
|
||||||
{
|
{
|
||||||
|
bufchain output;
|
||||||
|
bufchain_init(&output);
|
||||||
|
|
||||||
for (BufChar *bc = le->head; bc; bc = bc->next)
|
for (BufChar *bc = le->head; bc; bc = bc->next)
|
||||||
lineedit_send_data(le, make_ptrlen(bc->wire, bc->nwire));
|
bufchain_add(&output, bc->wire, bc->nwire);
|
||||||
|
|
||||||
|
while (bufchain_size(&output) > 0) {
|
||||||
|
ptrlen data = bufchain_prefix(&output);
|
||||||
|
lineedit_send_data(le, data);
|
||||||
|
bufchain_consume(&output, data.len);
|
||||||
|
}
|
||||||
|
bufchain_clear(&output);
|
||||||
|
|
||||||
lineedit_free_buffer(le);
|
lineedit_free_buffer(le);
|
||||||
le->quote_next_char = false;
|
le->quote_next_char = false;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user