From fb6550a242bb1742ec62202a99d0604ee9069795 Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Sat, 4 Mar 2017 02:46:40 -0800 Subject: Pipeline protocol now entirely callback driven. --- src/core/aio.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/core/aio.c') diff --git a/src/core/aio.c b/src/core/aio.c index a3f4fb28..ffc5ac06 100644 --- a/src/core/aio.c +++ b/src/core/aio.c @@ -12,20 +12,29 @@ #define NNI_AIO_WAKE (1<<0) -void +int nni_aio_init(nni_aio *aio, nni_cb cb, void *arg) { + int rv; + if (cb == NULL) { cb = (nni_cb) nni_aio_wake; arg = aio; } memset(aio, 0, sizeof (*aio)); - nni_mtx_init(&aio->a_lk); - nni_cv_init(&aio->a_cv, &aio->a_lk); + if ((rv = nni_mtx_init(&aio->a_lk)) != 0) { + return (rv); + } + if ((rv = nni_cv_init(&aio->a_cv, &aio->a_lk)) != 0) { + nni_mtx_fini(&aio->a_lk); + return (rv); + } aio->a_cb = cb; aio->a_cbarg = arg; aio->a_expire = NNI_TIME_NEVER; nni_taskq_ent_init(&aio->a_tqe, cb, arg); + + return (0); } -- cgit v1.2.3-70-g09d2