X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/a8cb2b6e5d990202130377e86280a6e1e3d52c02..f3e0acda46a71035ca81f7b352d7b61aa451ee23:/unix/uxnet.c diff --git a/unix/uxnet.c b/unix/uxnet.c index addfc769..7b970416 100644 --- a/unix/uxnet.c +++ b/unix/uxnet.c @@ -34,7 +34,7 @@ struct Socket_tag { Plug plug; void *private_ptr; bufchain output_data; - int connected; + int connected; /* irrelevant for listening sockets */ int writable; int frozen; /* this causes readability notifications to be ignored */ int frozen_readable; /* this means we missed at least one readability @@ -679,7 +679,6 @@ Socket sk_newlistener(char *srcaddr, int port, Plug plug, int local_host_only, i ret->oobpending = FALSE; ret->listener = 1; ret->addr = NULL; - ret->connected = 0; /* * Translate address_family from platform-independent constants @@ -912,11 +911,9 @@ void try_send(Actual_Socket s) */ s->writable = FALSE; return; - } else if (nsent == 0 || - err == ECONNABORTED || err == ECONNRESET) { + } else { /* - * If send() returns CONNABORTED or CONNRESET, we - * unfortunately can't just call plug_closing(), + * We unfortunately can't just call plug_closing(), * because it's quite likely that we're currently * _in_ a call from the code we'd be calling back * to, so we'd have to make half the SSH code @@ -926,11 +923,6 @@ void try_send(Actual_Socket s) */ s->pending_error = err; return; - } else { - /* We're inside the Unix frontend here, so we know - * that the frontend handle is unnecessary. */ - logevent(NULL, strerror(err)); - fatalbox("%s", strerror(err)); } } else { if (s->sending_oob) { @@ -1025,12 +1017,9 @@ static int net_select_result(int fd, int event) ret = recv(s->s, buf, sizeof(buf), MSG_OOB); noise_ultralight(ret); if (ret <= 0) { - const char *str = (ret == 0 ? "Internal networking trouble" : - strerror(errno)); - /* We're inside the Unix frontend here, so we know - * that the frontend handle is unnecessary. */ - logevent(NULL, str); - fatalbox("%s", str); + return plug_closing(s->plug, + ret == 0 ? "Internal networking trouble" : + strerror(errno), errno, 0); } else { /* * Receiving actual data on a socket means we can @@ -1254,14 +1243,16 @@ static void sk_tcp_set_frozen(Socket sock, int is_frozen) static void uxsel_tell(Actual_Socket s) { int rwx = 0; - if (!s->connected) - rwx |= 2; /* write == connect */ - if (s->connected && !s->frozen) - rwx |= 1 | 4; /* read, except */ - if (bufchain_size(&s->output_data)) - rwx |= 2; /* write */ - if (s->listener) - rwx |= 1; /* read == accept */ + if (s->listener) { + rwx |= 1; /* read == accept */ + } else { + if (!s->connected) + rwx |= 2; /* write == connect */ + if (s->connected && !s->frozen) + rwx |= 1 | 4; /* read, except */ + if (bufchain_size(&s->output_data)) + rwx |= 2; /* write */ + } uxsel_set(s->s, rwx, net_select_result); }