diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-03-12 10:08:05 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-03-12 10:08:05 -0700 |
| commit | 034e20abd05f17194727060e16a5adde571053ba (patch) | |
| tree | 3fd38df3d6cf3094cbd7ddf5465477105989c2d2 /src/core/taskq.c | |
| parent | 30a12e0d5746e0376780f74e3a1530a5b3fb2329 (diff) | |
| download | nng-034e20abd05f17194727060e16a5adde571053ba.tar.gz nng-034e20abd05f17194727060e16a5adde571053ba.tar.bz2 nng-034e20abd05f17194727060e16a5adde571053ba.zip | |
Fix leaking taskq data.
Diffstat (limited to 'src/core/taskq.c')
| -rw-r--r-- | src/core/taskq.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/core/taskq.c b/src/core/taskq.c index d473b65c..00b6d3cb 100644 --- a/src/core/taskq.c +++ b/src/core/taskq.c @@ -72,9 +72,9 @@ nni_taskq_init(nni_taskq **tqp, int nthr) if ((tq->tq_threads = nni_alloc(sizeof (nni_thr) * nthr)) == NULL) { return (NNG_ENOMEM); } - for (tq->tq_nthreads = 0; tq->tq_nthreads < nthr; tq->tq_nthreads++) { - rv = nni_thr_init(&tq->tq_threads[tq->tq_nthreads], - nni_taskq_thread, tq); + tq->tq_nthreads = nthr; + for (i = 0; i < nthr; i++) { + rv = nni_thr_init(&tq->tq_threads[i], nni_taskq_thread, tq); if (rv != 0) { goto fail; } @@ -105,6 +105,7 @@ nni_taskq_fini(nni_taskq *tq) for (i = 0; i < tq->tq_nthreads; i++) { nni_thr_fini(&tq->tq_threads[i]); } + nni_free(tq->tq_threads, tq->tq_nthreads * sizeof (nni_thr)); nni_cv_fini(&tq->tq_cv); nni_mtx_fini(&tq->tq_mtx); NNI_FREE_STRUCT(tq); |
