aboutsummaryrefslogtreecommitdiff
path: root/src/core/taskq.c
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2017-03-04 02:46:40 -0800
committerGarrett D'Amore <garrett@damore.org>2017-03-04 02:46:40 -0800
commitfb6550a242bb1742ec62202a99d0604ee9069795 (patch)
treebd235a8ddf6766dc54c3e47b31dbc7a59802d5da /src/core/taskq.c
parentc17a1dd3f5333da59355ecc3f8788a0396a8f72d (diff)
downloadnng-fb6550a242bb1742ec62202a99d0604ee9069795.tar.gz
nng-fb6550a242bb1742ec62202a99d0604ee9069795.tar.bz2
nng-fb6550a242bb1742ec62202a99d0604ee9069795.zip
Pipeline protocol now entirely callback driven.
Diffstat (limited to 'src/core/taskq.c')
-rw-r--r--src/core/taskq.c12
1 files changed, 10 insertions, 2 deletions
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);