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/core/aio.h | |
| 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/core/aio.h')
| -rw-r--r-- | src/core/aio.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/core/aio.h b/src/core/aio.h index 09923d7f..4f190aa1 100644 --- a/src/core/aio.h +++ b/src/core/aio.h @@ -104,8 +104,12 @@ extern int nni_aio_list_active(nni_aio *); // nni_aio_finish is called by the provider when an operation is complete. // The provider gives the result code (0 for success, an NNG errno otherwise), -// and the amount of data transferred (if any). -extern void nni_aio_finish(nni_aio *, int, size_t); +// and the amount of data transferred (if any). If the return code is +// non-zero, it indicates that the operation failed (usually because the aio +// was already canceled.) This is important for providers that need to +// prevent resources (new pipes for example) from accidentally leaking +// during close operations. +extern int nni_aio_finish(nni_aio *, int, size_t); // nni_aio_cancel is used to cancel an operation. Any pending I/O or // timeouts are canceled if possible, and the callback will be returned |
