diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-07-18 11:00:08 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-07-18 11:00:08 -0700 |
| commit | ab7772be3e3c208a48408b67924d3b58fca7f474 (patch) | |
| tree | b7355183556350de73303c6e75a5d278528dda0e /src/platform/posix | |
| parent | c41129ca0efacf13fe1363ed12f9723274c521e7 (diff) | |
| download | nng-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/posix')
| -rw-r--r-- | src/platform/posix/posix_epdesc.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/platform/posix/posix_epdesc.c b/src/platform/posix/posix_epdesc.c index a6de29e1..8cae2565 100644 --- a/src/platform/posix/posix_epdesc.c +++ b/src/platform/posix/posix_epdesc.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 @@ -72,8 +73,9 @@ nni_posix_epdesc_finish(nni_aio *aio, int rv, int newfd) aio->a_pipe = pd; } } - // Abuse the count to hold our new fd. This is only for accept. - nni_aio_finish(aio, rv, 0); + if ((nni_aio_finish(aio, rv, 0) != 0) && (rv == 0)) { + nni_posix_pipedesc_fini(pd); + } } static void |
