From 9f7ebadc564a72c01e28dd895d88e171e7952fe7 Mon Sep 17 00:00:00 2001 From: simon Date: Mon, 8 Jan 2007 19:38:39 +0000 Subject: [PATCH] The remaining issue in `win-askappend-multi' appears to have been caused by the MessageBox() internal message loop eating WinSock FD_READ notifications, which then don't reappear afterwards because you have to explicitly prod a socket in order to get a repeat notification on it. Hence, here's a piece of infrastructure which seems to sort it out: a new winnet.c function called socket_reselect_all(), whose function is to go through all currently active sockets and re-run WSAAsyncSelect() on them, causing repeat notifications for anything we might have missed. I call this after every call to MessageBox(), and that seems to solve the problem. (The problem was actually masked in very recent revisions, probably by the reinstatement of pending_netevent in r7071. However, I don't believe that was a complete fix. This should be.) git-svn-id: svn://svn.tartarus.org/sgt/putty@7077 cda61777-01e9-0310-a592-d414129be87e --- windows/windlg.c | 5 +++++ windows/winnet.c | 16 ++++++++++++++-- windows/winstuff.h | 2 ++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/windows/windlg.c b/windows/windlg.c index db1ef2f3..3a9d6e57 100644 --- a/windows/windlg.c +++ b/windows/windlg.c @@ -843,6 +843,7 @@ int askalg(void *frontend, const char *algtype, const char *algname, title = dupprintf(mbtitle, appname); mbret = MessageBox(NULL, message, title, MB_ICONWARNING | MB_YESNO | MB_DEFBUTTON2); + socket_reselect_all(); sfree(message); sfree(title); if (mbret == IDYES) @@ -875,6 +876,8 @@ int askappend(void *frontend, Filename filename, mbret = MessageBox(NULL, message, mbtitle, MB_ICONQUESTION | MB_YESNOCANCEL | MB_DEFBUTTON3); + socket_reselect_all(); + sfree(message); sfree(mbtitle); @@ -916,6 +919,8 @@ void old_keyfile_warning(void) MessageBox(NULL, msg, title, MB_OK); + socket_reselect_all(); + sfree(msg); sfree(title); } diff --git a/windows/winnet.c b/windows/winnet.c index f8838bec..a5fc3834 100644 --- a/windows/winnet.c +++ b/windows/winnet.c @@ -1473,10 +1473,11 @@ int select_result(WPARAM wParam, LPARAM lParam) #ifndef NO_IPV6 if (isa.ss_family == AF_INET && s->localhost_only && - !ipv4_is_local_addr(((struct sockaddr_in *)&isa)->sin_addr)) { + !ipv4_is_local_addr(((struct sockaddr_in *)&isa)->sin_addr)) #else - if (s->localhost_only && !ipv4_is_local_addr(isa.sin_addr)) { + if (s->localhost_only && !ipv4_is_local_addr(isa.sin_addr)) #endif + { p_closesocket(t); /* dodgy WinSock let nonlocal through */ } else if (plug_accepting(s->plug, (void*)t)) { p_closesocket(t); /* denied or error */ @@ -1572,6 +1573,17 @@ static void sk_tcp_set_frozen(Socket sock, int is_frozen) s->frozen_readable = 0; } +void socket_reselect_all(void) +{ + Actual_Socket s; + int i; + + for (i = 0; (s = index234(sktree, i)) != NULL; i++) { + if (!s->frozen) + do_select(s->s, 1); + } +} + /* * For Plink: enumerate all sockets currently active. */ diff --git a/windows/winstuff.h b/windows/winstuff.h index 2d8ac956..4ece0630 100644 --- a/windows/winstuff.h +++ b/windows/winstuff.h @@ -202,6 +202,8 @@ extern int (WINAPI *p_WSAEnumNetworkEvents) extern int socket_writable(SOCKET skt); +extern void socket_reselect_all(void); + /* * Exports from winctrls.c. */ -- 2.11.0