From b7a11a0e9e5655da3198e36495d143ea03de91bb Mon Sep 17 00:00:00 2001 From: Garrett D'Amore Date: Wed, 6 May 2020 22:07:42 -0700 Subject: fixes #1236 Deadlock triggered on nng_close fixes #1219 nng_close occasionally hang on Windows --- src/core/taskq.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/core/taskq.c') diff --git a/src/core/taskq.c b/src/core/taskq.c index e63e33c7..fbd93ebe 100644 --- a/src/core/taskq.c +++ b/src/core/taskq.c @@ -183,6 +183,20 @@ nni_task_prep(nni_task *task) nni_mtx_unlock(&task->task_mtx); } +void +nni_task_abort(nni_task *task) +{ + // This is called when unscheduling the task. + nni_mtx_lock(&task->task_mtx); + if (task->task_prep) { + task->task_prep = false; + task->task_busy--; + if (task->task_busy == 0) { + nni_cv_wake(&task->task_cv); + } + } + nni_mtx_unlock(&task->task_mtx); +} void nni_task_wait(nni_task *task) { -- cgit v1.2.3-70-g09d2