diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-07-18 19:52:08 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-07-18 19:52:08 -0700 |
| commit | 5fb832e06fd4ded6ccc45f943837fd374a9cea7a (patch) | |
| tree | 41c306c297911d740e92f38b98685207f77758c6 /src/core/aio.c | |
| parent | 3eb60946ae8b5ad7d8a95233ffe946432acdb837 (diff) | |
| download | nng-5fb832e06fd4ded6ccc45f943837fd374a9cea7a.tar.gz nng-5fb832e06fd4ded6ccc45f943837fd374a9cea7a.tar.bz2 nng-5fb832e06fd4ded6ccc45f943837fd374a9cea7a.zip | |
Fixes most of the raaces in posix; but at least one remains outstanding.
Apparently there are circumstances when a pipedesc may get orphaned form the
pollq. This triggers an assertion failure when it occurs. I am still
trying to understand how this can occur. Stay tuned.
Diffstat (limited to 'src/core/aio.c')
| -rw-r--r-- | src/core/aio.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/core/aio.c b/src/core/aio.c index f9927e9d..238522b0 100644 --- a/src/core/aio.c +++ b/src/core/aio.c @@ -228,6 +228,32 @@ nni_aio_finish(nni_aio *aio, int result, size_t count) return (0); } +int +nni_aio_finish_pipe(nni_aio *aio, int result, void *pipe) +{ + 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 (NNG_ESTATE); + } + aio->a_flags |= NNI_AIO_DONE; + aio->a_result = result; + aio->a_count = 0; + aio->a_prov_cancel = NULL; + aio->a_prov_data = NULL; + aio->a_pipe = pipe; + + // This is guaranteed to just be a list operation at this point, + // because done wasn't set. + nni_aio_expire_remove(aio); + aio->a_expire = NNI_TIME_NEVER; + + nni_taskq_dispatch(NULL, &aio->a_tqe); + nni_mtx_unlock(&aio->a_lk); + return (0); +} + void nni_aio_list_init(nni_list *list) { |
