From f65c31667e0dee8d416df41dac66198a80c3314b Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Mon, 30 May 2016 20:47:04 +0100 Subject: [PATCH] winplink: remove "connopen" variable. It's redundant with back->connected(): only the SSH backend has a receive function that can ever return 0, and whenever ssh_receive returns 0 it has called ssh_do_close, which will cause future calls to ssh_connected also to return 0. Similarly, all backend closing functions ensure that future calls to their connected function will return 0. --- windows/winplink.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/windows/winplink.c b/windows/winplink.c index 47470777..a1a8dda0 100644 --- a/windows/winplink.c +++ b/windows/winplink.c @@ -87,7 +87,6 @@ void cmdline_error(const char *p, ...) HANDLE inhandle, outhandle, errhandle; struct handle *stdin_handle, *stdout_handle, *stderr_handle; DWORD orig_console_mode; -int connopen; WSAEVENT netevent; @@ -267,7 +266,7 @@ int stdin_gotdata(struct handle *h, void *data, int len) cleanup_exit(0); } noise_ultralight(len); - if (connopen && back->connected(backhandle)) { + if (back->connected(backhandle)) { if (len > 0) { return back->send(backhandle, data, len); } else { @@ -294,7 +293,7 @@ void stdouterr_sent(struct handle *h, int new_backlog) (h == stdout_handle ? "output" : "error"), buf); cleanup_exit(0); } - if (connopen && back->connected(backhandle)) { + if (back->connected(backhandle)) { back->unthrottle(backhandle, (handle_backlog(stdout_handle) + handle_backlog(stderr_handle))); } @@ -662,7 +661,6 @@ int main(int argc, char **argv) back->provide_logctx(backhandle, logctx); sfree(realhost); } - connopen = 1; inhandle = GetStdHandle(STD_INPUT_HANDLE); outhandle = GetStdHandle(STD_OUTPUT_HANDLE); @@ -782,7 +780,7 @@ int main(int argc, char **argv) LPARAM lp; int err = things.iErrorCode[eventtypes[e].bit]; lp = WSAMAKESELECTREPLY(eventtypes[e].mask, err); - connopen &= select_result(wp, lp); + select_result(wp, lp); } } } @@ -810,7 +808,7 @@ int main(int argc, char **argv) if (sending) handle_unthrottle(stdin_handle, back->sendbuffer(backhandle)); - if ((!connopen || !back->connected(backhandle)) && + if (!back->connected(backhandle) && handle_backlog(stdout_handle) + handle_backlog(stderr_handle) == 0) break; /* we closed the connection */ }