X-Git-Url: https://git.distorted.org.uk/u/mdw/putty/blobdiff_plain/6f81f628c3273ff6644bc7a32661a05c62d31db0..4fa38586e9af919db6853d0436ea96478bdec477:/mac/otnet.c diff --git a/mac/otnet.c b/mac/otnet.c index 4c9ec4b4..eb24b85c 100644 --- a/mac/otnet.c +++ b/mac/otnet.c @@ -74,12 +74,14 @@ void ot_cleanup(void) CloseOpenTransport(); } -SockAddr ot_namelookup(char *host, char **canonicalname) +SockAddr ot_namelookup(char const *host, char **canonicalname) { SockAddr ret = smalloc(sizeof(struct SockAddr_tag)); char *realhost; - - ret->error = OTInetStringToAddress(ot.inetsvc, host, &ret->hostinfo); + + /* Casting away const -- hope OTInetStringToAddress is sensible */ + ret->error = OTInetStringToAddress(ot.inetsvc, (char *)host, + &ret->hostinfo); ret->resolved = TRUE; if (ret->error == kOTNoError) @@ -91,7 +93,7 @@ SockAddr ot_namelookup(char *host, char **canonicalname) return ret; } -SockAddr ot_nonamelookup(char *host) +SockAddr ot_nonamelookup(char const *host) { SockAddr ret = smalloc(sizeof(struct SockAddr_tag)); @@ -313,6 +315,8 @@ Socket ot_new(SockAddr addr, int port, int privport, int oobinline, /* Add this to the list of all sockets */ ret->next = ot.socklist; ret->prev = &ot.socklist; + if (ret->next != NULL) + ret->next->prev = &ret->next; ot.socklist = ret; return (Socket) ret; @@ -462,9 +466,13 @@ void ot_recv(Actual_Socket s) if (s->frozen) return; - while ((o = OTRcv(s->ep, buf, sizeof(buf), &flags)) != kOTNoDataErr) { - plug_receive(s->plug, 0, buf, sizeof(buf)); - } + do { + o = OTRcv(s->ep, buf, sizeof(buf), &flags); + if (o > 0) + plug_receive(s->plug, 0, buf, o); + if (o < 0 && o != kOTNoDataErr) + plug_closing(s->plug, NULL, 0, 0); /* XXX Error msg */ + } while (o > 0); }