[PATCH] threadpool: Don't wait on condition if pool has no workers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Pool creates new workers dynamically. However, it is possible
for a pool to have no workers. If we want to free that pool,
we don't want to wait on quit condition as it will never be
signaled.
---
Pushing under trivial rule

 src/util/threadpool.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/src/util/threadpool.c b/src/util/threadpool.c
index c16e2af..883d1e5 100644
--- a/src/util/threadpool.c
+++ b/src/util/threadpool.c
@@ -258,7 +258,8 @@ void virThreadPoolFree(virThreadPoolPtr pool)
         virCondBroadcast(&pool->prioCond);
     }
 
-    ignore_value(virCondWait(&pool->quit_cond, &pool->mutex));
+    if (pool->nWorkers > 0 || pool->nPrioWorkers > 0)
+        ignore_value(virCondWait(&pool->quit_cond, &pool->mutex));
 
     while ((job = pool->jobList.head)) {
         pool->jobList.head = pool->jobList.head->next;
-- 
1.7.3.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]