aboutsummaryrefslogtreecommitdiff
path: root/src/platform/windows/win_ipc.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2017-07-18 11:00:08 -0700
committerGarrett D'Amore <garrett@damore.org>2017-07-18 11:00:08 -0700
commitab7772be3e3c208a48408b67924d3b58fca7f474 (patch)
treeb7355183556350de73303c6e75a5d278528dda0e /src/platform/windows/win_ipc.c
parentc41129ca0efacf13fe1363ed12f9723274c521e7 (diff)
downloadnng-ab7772be3e3c208a48408b67924d3b58fca7f474.tar.gz
nng-ab7772be3e3c208a48408b67924d3b58fca7f474.tar.bz2
nng-ab7772be3e3c208a48408b67924d3b58fca7f474.zip
Fix close-related leak of pipes.
We have seen leaks of pipes causing test failures (e.g. the Windows IPC test) due to EADDRINUSE. This was caused by a case where we failed to pass the pipe up because the AIO had already been canceled, and we didn't realize that we had oprhaned the pipe. The fix is to add a return value to nni_aio_finish, and verify that we did finish properly, or if we did not then we must free the pipe ourself. (The zero return from nni_aio_finish indicates that it accepts ownership of resources passed via the aio.)
Diffstat (limited to 'src/platform/windows/win_ipc.c')
-rw-r--r--src/platform/windows/win_ipc.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/platform/windows/win_ipc.c b/src/platform/windows/win_ipc.c
index 1a672c70..85e3dfca 100644
--- a/src/platform/windows/win_ipc.c
+++ b/src/platform/windows/win_ipc.c
@@ -1,5 +1,6 @@
//
// Copyright 2017 Garrett D'Amore <garrett@damore.org>
+// Copyright 2017 Capitar IT Group BV <info@capitar.com>
//
// This software is supplied under the terms of the MIT License, a
// copy of which should be located in the distribution where this
@@ -333,7 +334,10 @@ nni_win_ipc_acc_finish(nni_win_event *evt, nni_aio *aio)
}
aio->a_pipe = pipe;
- nni_aio_finish(aio, 0, 0);
+ // What if the pipe is already finished?
+ if (nni_aio_finish(aio, 0, 0) != 0) {
+ nni_plat_ipc_pipe_fini(pipe);
+ }
}
static void
@@ -559,8 +563,8 @@ nni_plat_ipc_ep_close(nni_plat_ipc_ep *ep)
break;
case NNI_EP_MODE_LISTEN:
+ nni_win_event_close(&ep->acc_ev);
if (ep->p != INVALID_HANDLE_VALUE) {
- nni_win_event_close(&ep->acc_ev);
CloseHandle(ep->p);
ep->p = INVALID_HANDLE_VALUE;
}