diff --git a/src/util/virthreadpool.c b/src/util/virthreadpool.c index b1e2c0cbea..99f36ec13b 100644 --- a/src/util/virthreadpool.c +++ b/src/util/virthreadpool.c @@ -241,6 +241,9 @@ void virThreadPoolFree(virThreadPoolPtr pool) { virThreadPoolJobPtr job; bool priority = false; + size_t i; + size_t nWorkers = pool->nWorkers; + size_t nPrioWorkers = pool->nPrioWorkers; if (!pool) return; @@ -262,6 +265,12 @@ void virThreadPoolFree(virThreadPoolPtr pool) VIR_FREE(job); } + for (i = 0; i < nWorkers; i++) + virThreadJoin(&pool->workers[i]); + + for (i = 0; i < nPrioWorkers; i++) + virThreadJoin(&pool->prioWorkers[i]); + VIR_FREE(pool->workers); virMutexUnlock(&pool->mutex); virMutexDestroy(&pool->mutex);