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/taskq.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/core/taskq.c') diff --git a/src/core/taskq.c b/src/core/taskq.c index 2b2b0d1a..d473b65c 100644 --- a/src/core/taskq.c +++ b/src/core/taskq.c @@ -33,6 +33,7 @@ nni_taskq_thread(void *self) ent->tqe_tq = NULL; nni_mtx_unlock(&tq->tq_mtx); ent->tqe_cb(ent->tqe_arg); + nni_mtx_lock(&tq->tq_mtx); continue; } @@ -56,8 +57,15 @@ nni_taskq_init(nni_taskq **tqp, int nthr) if ((tq = NNI_ALLOC_STRUCT(tq)) == NULL) { return (NNG_ENOMEM); } - nni_mtx_init(&tq->tq_mtx); - nni_cv_init(&tq->tq_cv, &tq->tq_mtx); + if ((rv = nni_mtx_init(&tq->tq_mtx)) != 0) { + NNI_FREE_STRUCT(tq); + return (rv); + } + if ((rv = nni_cv_init(&tq->tq_cv, &tq->tq_mtx)) != 0) { + nni_mtx_fini(&tq->tq_mtx); + NNI_FREE_STRUCT(tq); + return (rv); + } tq->tq_close = 0; NNI_LIST_INIT(&tq->tq_ents, nni_taskq_ent, tqe_node); -- cgit v1.2.3-70-g09d2