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 */ }