[libvirt] [PATCH 4/6] virThreadPoolFree: Join worker threads

Michal Privoznik mprivozn at redhat.com
Thu Nov 14 09:51:14 UTC 2013


Even though currently we are freeing the pool of worker threads at the
daemon very end, nothing holds us back in joining the worker threads.

Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
 src/util/virthreadpool.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/src/util/virthreadpool.c b/src/util/virthreadpool.c
index b1e2c0c..99f36ec 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);
-- 
1.8.3.2




More information about the libvir-list mailing list