X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/7e78000d8966255e919e3d8753fd784f4559ee55..01c034ad857128c51482a563befb374e38ebe668:/winnet.c diff --git a/winnet.c b/winnet.c index 01b4f1ba..7d927917 100644 --- a/winnet.c +++ b/winnet.c @@ -54,7 +54,7 @@ #include "network.h" #include "tree234.h" -#define BUFFER_GRANULE 512 +#define BUFFER_GRANULE 512 struct Socket_tag { struct socket_function_table *fn; @@ -287,10 +287,10 @@ SockAddr sk_namelookup(char *host, char **canonicalname) } else { - /* - * Hack inserted to deal with problems with numeric IPs. - * FIXME: how will this work in IPv6? - */ + /* + * This must be a numeric IPv4 address because it caused a + * success return from inet_addr. + */ ret->family = AF_INET; *canonicalname = host; } @@ -504,8 +504,15 @@ void try_send(Actual_Socket s) { noise_ultralight(nsent); if (nsent <= 0) { err = (nsent < 0 ? WSAGetLastError() : 0); - if (err == WSAEWOULDBLOCK) { - /* Perfectly normal: we've sent all we can for the moment. */ + if ((err==0 && nsent < 0) || err == WSAEWOULDBLOCK) { + /* + * Perfectly normal: we've sent all we can for the moment. + * + * (Apparently some WinSocks can return <0 but + * leave no error indication - WSAGetLastError() is + * called but returns zero - so we check that case + * and treat it just like WSAEWOULDBLOCK.) + */ s->writable = FALSE; return; } else if (nsent == 0 || @@ -614,7 +621,7 @@ static void sk_tcp_write_oob(Socket sock, char *buf, int len) { int select_result(WPARAM wParam, LPARAM lParam) { int ret, open; DWORD err; - char buf[BUFFER_GRANULE]; + char buf[20480]; /* nice big buffer for plenty of speed */ Actual_Socket s; u_long atmark; @@ -740,11 +747,13 @@ static char *sk_tcp_socket_error(Socket sock) { /* * For Plink: enumerate all sockets currently active. */ -SOCKET first_socket(enum234 *e) { - Actual_Socket s = first234(sktree, e); +SOCKET first_socket(int *state) { + Actual_Socket s; + *state = 0; + s = index234(sktree, (*state)++); return s ? s->s : INVALID_SOCKET; } -SOCKET next_socket(enum234 *e) { - Actual_Socket s = next234(e); +SOCKET next_socket(int *state) { + Actual_Socket s = index234(sktree, (*state)++); return s ? s->s : INVALID_SOCKET; }