mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 17:38:00 +00:00
Unix Plink: fix tight loop after EOF on stdin.
When Plink saw EOF on stdin, it would continue to put stdin in its list of poll fds, so that the poll loop would always terminate instantly with stdin readable. Plink would read from it, see EOF again, go back to the poll loop, and keep spinning like that. This was supposed to be fixed by the 'sending' flag, which was set to false on seeing EOF to indicate that we were no longer interested in reading stdin data to send to the SSH server. But that flag was ineffective, because it turns out it was _always_ set to false - nothing in the code ever set it to true! And the reason why that didn't totally prevent reading from stdin at all is because it was also tested with the wrong sense. How embarrassing. Changed the flag name to 'seen_stdin_eof', and made it behave sensibly.
This commit is contained in:
parent
9e1ec093fd
commit
af278ac870
@ -572,13 +572,13 @@ const unsigned cmdline_tooltype =
|
||||
TOOLTYPE_HOST_ARG_PROTOCOL_PREFIX |
|
||||
TOOLTYPE_HOST_ARG_FROM_LAUNCHABLE_LOAD;
|
||||
|
||||
static bool sending;
|
||||
static bool seen_stdin_eof = false;
|
||||
|
||||
static bool plink_pw_setup(void *vctx, pollwrapper *pw)
|
||||
{
|
||||
pollwrap_add_fd_rwx(pw, signalpipe[0], SELECT_R);
|
||||
|
||||
if (!sending &&
|
||||
if (!seen_stdin_eof &&
|
||||
backend_connected(backend) &&
|
||||
backend_sendok(backend) &&
|
||||
backend_sendbuffer(backend) < MAX_STDIN_BACKLOG) {
|
||||
@ -623,7 +623,7 @@ static void plink_pw_check(void *vctx, pollwrapper *pw)
|
||||
exit(1);
|
||||
} else if (ret == 0) {
|
||||
backend_special(backend, SS_EOF, 0);
|
||||
sending = false; /* send nothing further after this */
|
||||
seen_stdin_eof = true;
|
||||
} else {
|
||||
if (local_tty)
|
||||
from_tty(buf, ret);
|
||||
@ -948,7 +948,6 @@ int main(int argc, char **argv)
|
||||
local_tty = (tcgetattr(STDIN_FILENO, &orig_termios) == 0);
|
||||
atexit(cleanup_termios);
|
||||
seat_echoedit_update(plink_seat, 1, 1);
|
||||
sending = false;
|
||||
|
||||
cli_main_loop(plink_pw_setup, plink_pw_check, plink_continue, NULL);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user