The remaining issue in `win-askappend-multi' appears to have been
authorsimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Mon, 8 Jan 2007 19:38:39 +0000 (19:38 +0000)
committersimon <simon@cda61777-01e9-0310-a592-d414129be87e>
Mon, 8 Jan 2007 19:38:39 +0000 (19:38 +0000)
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
windows/winnet.c
windows/winstuff.h

index db1ef2f..3a9d6e5 100644 (file)
@@ -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);
 }
index f8838be..a5fc383 100644 (file)
@@ -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.
  */
index 2d8ac95..4ece063 100644 (file)
@@ -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.
  */