Re: [PATCH 02/10] util: always initialize priority condition

2020-07-21 Thread Daniel P . Berrangé
On Tue, Jul 14, 2020 at 12:32:53PM +0300, Nikolay Shirokovskiy wrote:
> Even if we have no priority threads on pool creation we can add them thru
> virThreadPoolSetParameters later.
> 
> Signed-off-by: Nikolay Shirokovskiy 
> ---
>  src/util/virthreadpool.c | 22 +++---
>  1 file changed, 7 insertions(+), 15 deletions(-)

Reviewed-by: Daniel P. Berrangé 

Regards,
Daniel
-- 
|: https://berrange.com  -o-https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o-https://fstop138.berrange.com :|
|: https://entangle-photo.org-o-https://www.instagram.com/dberrange :|



[PATCH 02/10] util: always initialize priority condition

2020-07-14 Thread Nikolay Shirokovskiy
Even if we have no priority threads on pool creation we can add them thru
virThreadPoolSetParameters later.

Signed-off-by: Nikolay Shirokovskiy 
---
 src/util/virthreadpool.c | 22 +++---
 1 file changed, 7 insertions(+), 15 deletions(-)

diff --git a/src/util/virthreadpool.c b/src/util/virthreadpool.c
index 379d236..10a44de 100644
--- a/src/util/virthreadpool.c
+++ b/src/util/virthreadpool.c
@@ -245,6 +245,8 @@ virThreadPoolNewFull(size_t minWorkers,
 goto error;
 if (virCondInit(>cond) < 0)
 goto error;
+if (virCondInit(>prioCond) < 0)
+goto error;
 if (virCondInit(>quit_cond) < 0)
 goto error;
 
@@ -255,13 +257,8 @@ virThreadPoolNewFull(size_t minWorkers,
 if (virThreadPoolExpand(pool, minWorkers, false) < 0)
 goto error;
 
-if (prioWorkers) {
-if (virCondInit(>prioCond) < 0)
-goto error;
-
-if (virThreadPoolExpand(pool, prioWorkers, true) < 0)
-goto error;
-}
+if (virThreadPoolExpand(pool, prioWorkers, true) < 0)
+goto error;
 
 return pool;
 
@@ -274,7 +271,6 @@ virThreadPoolNewFull(size_t minWorkers,
 void virThreadPoolFree(virThreadPoolPtr pool)
 {
 virThreadPoolJobPtr job;
-bool priority = false;
 
 if (!pool)
 return;
@@ -283,10 +279,8 @@ void virThreadPoolFree(virThreadPoolPtr pool)
 pool->quit = true;
 if (pool->nWorkers > 0)
 virCondBroadcast(>cond);
-if (pool->nPrioWorkers > 0) {
-priority = true;
+if (pool->nPrioWorkers > 0)
 virCondBroadcast(>prioCond);
-}
 
 while (pool->nWorkers > 0 || pool->nPrioWorkers > 0)
 ignore_value(virCondWait(>quit_cond, >mutex));
@@ -301,10 +295,8 @@ void virThreadPoolFree(virThreadPoolPtr pool)
 virMutexDestroy(>mutex);
 virCondDestroy(>quit_cond);
 virCondDestroy(>cond);
-if (priority) {
-VIR_FREE(pool->prioWorkers);
-virCondDestroy(>prioCond);
-}
+VIR_FREE(pool->prioWorkers);
+virCondDestroy(>prioCond);
 VIR_FREE(pool);
 }
 
-- 
1.8.3.1