diff --git a/windows/window.c b/windows/window.c index f9e09aa3..a17a9854 100644 --- a/windows/window.c +++ b/windows/window.c @@ -1026,10 +1026,10 @@ void cleanup_exit(int code) /* * Set up, or shut down, an AsyncSelect. Called from winnet.c. */ -char *do_select(SOCKET skt, bool startup) +char *do_select(SOCKET skt, bool enable) { int msg, events; - if (startup) { + if (enable) { msg = WM_NETEVENT; events = (FD_CONNECT | FD_READ | FD_WRITE | FD_OOB | FD_CLOSE | FD_ACCEPT); diff --git a/windows/winplink.c b/windows/winplink.c index dce5691f..39ca8fb5 100644 --- a/windows/winplink.c +++ b/windows/winplink.c @@ -190,10 +190,10 @@ static void version(void) exit(0); } -char *do_select(SOCKET skt, bool startup) +char *do_select(SOCKET skt, bool enable) { int events; - if (startup) { + if (enable) { events = (FD_CONNECT | FD_READ | FD_WRITE | FD_OOB | FD_CLOSE | FD_ACCEPT); } else { diff --git a/windows/winsftp.c b/windows/winsftp.c index b120890c..91c3f2fd 100644 --- a/windows/winsftp.c +++ b/windows/winsftp.c @@ -467,19 +467,21 @@ char *dir_file_cat(const char *dir, const char *file) */ static SOCKET sftp_ssh_socket = INVALID_SOCKET; static HANDLE netevent = INVALID_HANDLE_VALUE; -char *do_select(SOCKET skt, bool startup) +char *do_select(SOCKET skt, bool enable) { int events; - if (startup) + if (enable) sftp_ssh_socket = skt; else sftp_ssh_socket = INVALID_SOCKET; + if (netevent == INVALID_HANDLE_VALUE) + netevent = CreateEvent(NULL, false, false, NULL); + if (p_WSAEventSelect) { - if (startup) { + if (enable) { events = (FD_CONNECT | FD_READ | FD_WRITE | FD_OOB | FD_CLOSE | FD_ACCEPT); - netevent = CreateEvent(NULL, false, false, NULL); } else { events = 0; } @@ -732,7 +734,9 @@ char *ssh_sftp_get_cmdline(const char *prompt, bool no_fds_ok) do { ret = do_eventsel_loop(ctx->event); - /* Error return can only occur if netevent==NULL, and it ain't. */ + /* do_eventsel_loop can't return an error (unlike + * ssh_sftp_loop_iteration, which can return -1 if select goes + * wrong or if the socket doesn't exist). */ assert(ret >= 0); } while (ret == 0); diff --git a/windows/winstuff.h b/windows/winstuff.h index 0b191d54..c189c37a 100644 --- a/windows/winstuff.h +++ b/windows/winstuff.h @@ -350,7 +350,7 @@ DECL_WINDOWS_FUNCTION(GLOBAL, int, select, * Provided by each client of winnet.c, and called by winnet.c to turn * on or off WSA*Select for a given socket. */ -char *do_select(SOCKET skt, bool startup); +char *do_select(SOCKET skt, bool enable); /* * Network-subsystem-related functions provided in other Windows modules.