Missed out a couple of uxsel_tell() which were hanging forwarded X
[u/mdw/putty] / unix / uxnet.c
index f4731fd..9d9e03b 100644 (file)
@@ -383,6 +383,7 @@ Socket sk_new(SockAddr addr, int port, int privport, int oobinline,
     int err;
     Actual_Socket ret;
     short localport;
+    int fl;
 
     /*
      * Create Socket structure.
@@ -492,10 +493,10 @@ Socket sk_new(SockAddr addr, int port, int privport, int oobinline,
     a.sin_addr.s_addr = htonl(addr->address);
     a.sin_port = htons((short) port);
 #endif
-    {
-       int i = 1;
-       ioctl(s, FIONBIO, &i);
-    }
+
+    fl = fcntl(s, F_GETFL);
+    if (fl != -1)
+       fcntl(s, F_SETFL, fl | O_NONBLOCK);
 
     if ((
 #ifdef IPV6
@@ -773,6 +774,12 @@ static int sk_tcp_write(Socket sock, const char *buf, int len)
     if (s->writable)
        try_send(s);
 
+    /*
+     * Update the select() status to correctly reflect whether or
+     * not we should be selecting for write.
+     */
+    uxsel_tell(s);
+
     return bufchain_size(&s->output_data);
 }
 
@@ -794,6 +801,12 @@ static int sk_tcp_write_oob(Socket sock, const char *buf, int len)
     if (s->writable)
        try_send(s);
 
+    /*
+     * Update the select() status to correctly reflect whether or
+     * not we should be selecting for write.
+     */
+    uxsel_tell(s);
+
     return s->sending_oob;
 }