diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-12-28 16:02:53 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-12-28 16:02:53 -0800 |
| commit | aa3bb50aeca3b7350a41f0538817c49d9656d207 (patch) | |
| tree | 4abafbdc7553e52776394e067fa1ff9a08a14a57 /src/platform/windows/win_tcp.c | |
| parent | 838d92deabffbaae1b1a9e447d2088f966078726 (diff) | |
| download | nng-aa3bb50aeca3b7350a41f0538817c49d9656d207.tar.gz nng-aa3bb50aeca3b7350a41f0538817c49d9656d207.tar.bz2 nng-aa3bb50aeca3b7350a41f0538817c49d9656d207.zip | |
Fix compilation warnings, bugs, and crashes found on Windows.
This addresses a number of problems that were found on Windows,
including one bug that actually turned up in testing on POSIX.
Diffstat (limited to 'src/platform/windows/win_tcp.c')
| -rw-r--r-- | src/platform/windows/win_tcp.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/platform/windows/win_tcp.c b/src/platform/windows/win_tcp.c index 01818af4..93cead91 100644 --- a/src/platform/windows/win_tcp.c +++ b/src/platform/windows/win_tcp.c @@ -163,6 +163,12 @@ nni_win_tcp_pipe_cancel(nni_win_event *evt) static void nni_win_tcp_pipe_finish(nni_win_event *evt, nni_aio *aio) { + if ((evt->status == 0) && (evt->count == 0)) { + // Windows sometimes returns a zero read. Convert these + // into an NNG_ECLOSED. (We are never supposed to come + // back with zero length read.) + evt->status = NNG_ECLOSED; + } nni_aio_finish(aio, evt->status, evt->count); } @@ -263,10 +269,10 @@ nni_plat_tcp_ep_init(nni_plat_tcp_ep **epp, const nni_sockaddr *lsa, ep->s = INVALID_SOCKET; - if (rsa->s_un.s_family != NNG_AF_UNSPEC) { + if ((rsa != NULL) && (rsa->s_un.s_family != NNG_AF_UNSPEC)) { ep->remlen = nni_win_nn2sockaddr(&ep->remaddr, rsa); } - if (lsa->s_un.s_family != NNG_AF_UNSPEC) { + if ((lsa != NULL) && (lsa->s_un.s_family != NNG_AF_UNSPEC)) { ep->loclen = nni_win_nn2sockaddr(&ep->locaddr, lsa); } |
