diff options
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/aio.c | 7 | ||||
| -rw-r--r-- | src/core/aio.h | 8 | ||||
| -rw-r--r-- | src/core/endpt.c | 2 | ||||
| -rw-r--r-- | src/core/socket.c | 3 |
4 files changed, 12 insertions, 8 deletions
diff --git a/src/core/aio.c b/src/core/aio.c index 73c1dd9b..c6512eb4 100644 --- a/src/core/aio.c +++ b/src/core/aio.c @@ -206,14 +206,14 @@ nni_aio_cancel(nni_aio *aio, int rv) // I/O provider related functions. -void +int nni_aio_finish(nni_aio *aio, int result, size_t count) { nni_mtx_lock(&aio->a_lk); if (aio->a_flags & (NNI_AIO_DONE | NNI_AIO_FINI)) { // Operation already done (canceled or timed out?) nni_mtx_unlock(&aio->a_lk); - return; + return (NNG_ESTATE); } aio->a_flags |= NNI_AIO_DONE; aio->a_result = result; @@ -228,6 +228,7 @@ nni_aio_finish(nni_aio *aio, int result, size_t count) nni_taskq_dispatch(NULL, &aio->a_tqe); nni_mtx_unlock(&aio->a_lk); + return (0); } void @@ -307,7 +308,7 @@ nni_aio_expire_loop(void *arg) nni_list *aios = &nni_aio_expire_aios; nni_aio * aio; nni_time now; - int rv; + void (*cancelfn)(nni_aio *); NNI_ARG_UNUSED(arg); 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 diff --git a/src/core/endpt.c b/src/core/endpt.c index 4ed678d7..8048de2b 100644 --- a/src/core/endpt.c +++ b/src/core/endpt.c @@ -397,7 +397,7 @@ nni_ep_accept_start(nni_ep *ep) if (ep->ep_closed) { return; } - + aio->a_pipe = NULL; aio->a_endpt = ep->ep_data; ep->ep_ops.ep_accept(ep->ep_data, aio); } diff --git a/src/core/socket.c b/src/core/socket.c index 7ec383d4..10bc1c80 100644 --- a/src/core/socket.c +++ b/src/core/socket.c @@ -124,8 +124,7 @@ nni_sock_pipe_ready(nni_sock *sock, nni_pipe *pipe) void nni_sock_pipe_remove(nni_sock *sock, nni_pipe *pipe) { - void * pdata; - nni_ep *ep; + void *pdata; pdata = nni_pipe_get_proto_data(pipe); |
