aboutsummaryrefslogtreecommitdiff
path: root/src/platform
diff options
context:
space:
mode:
Diffstat (limited to 'src/platform')
-rw-r--r--src/platform/posix/posix_epdesc.c2
-rw-r--r--src/platform/windows/win_tcp.c10
-rw-r--r--src/platform/windows/win_thread.c9
3 files changed, 14 insertions, 7 deletions
diff --git a/src/platform/posix/posix_epdesc.c b/src/platform/posix/posix_epdesc.c
index 80711ed0..7b168679 100644
--- a/src/platform/posix/posix_epdesc.c
+++ b/src/platform/posix/posix_epdesc.c
@@ -318,6 +318,7 @@ nni_posix_epdesc_accept(nni_posix_epdesc *ed, nni_aio *aio)
// connection is ready for us. There isn't anything else for us to
// do really, as that will have been done in listen.
nni_mtx_lock(&ed->mtx);
+ aio->a_pipe = NULL;
// If we can't start, it means that the AIO was stopped.
if ((rv = nni_aio_start(aio, nni_posix_epdesc_cancel, ed)) != 0) {
nni_mtx_unlock(&ed->mtx);
@@ -343,6 +344,7 @@ nni_posix_epdesc_connect(nni_posix_epdesc *ed, nni_aio *aio)
int fd;
nni_mtx_lock(&ed->mtx);
+ aio->a_pipe = NULL;
// If we can't start, it means that the AIO was stopped.
if ((rv = nni_aio_start(aio, nni_posix_epdesc_cancel, ed)) != 0) {
nni_mtx_unlock(&ed->mtx);
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);
}
diff --git a/src/platform/windows/win_thread.c b/src/platform/windows/win_thread.c
index 0d9e7387..6cfb4162 100644
--- a/src/platform/windows/win_thread.c
+++ b/src/platform/windows/win_thread.c
@@ -14,20 +14,19 @@
#ifdef NNG_PLATFORM_WINDOWS
+#include <stdlib.h>
+
void *
nni_alloc(size_t sz)
{
- void *v;
-
- v = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sz);
- return (v);
+ return (calloc(sz, 1));
}
void
nni_free(void *b, size_t z)
{
NNI_ARG_UNUSED(z);
- HeapFree(GetProcessHeap(), 0, b);
+ free(b);
}
void