File 018e213f-always-init-prio-cond.patch of Package libvirt.22291
commit 018e213f5d1bbf5a68b7b7d46c8bacec06d97d49
Author: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Date: Fri Jul 10 14:36:54 2020 +0300
util: always initialize priority condition
Even if we have no priority threads on pool creation we can add them thru
virThreadPoolSetParameters later.
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Index: libvirt-6.0.0/src/util/virthreadpool.c
===================================================================
--- libvirt-6.0.0.orig/src/util/virthreadpool.c
+++ libvirt-6.0.0/src/util/virthreadpool.c
@@ -239,6 +239,8 @@ virThreadPoolNewFull(size_t minWorkers,
goto error;
if (virCondInit(&pool->cond) < 0)
goto error;
+ if (virCondInit(&pool->prioCond) < 0)
+ goto error;
if (virCondInit(&pool->quit_cond) < 0)
goto error;
@@ -249,13 +251,8 @@ virThreadPoolNewFull(size_t minWorkers,
if (virThreadPoolExpand(pool, minWorkers, false) < 0)
goto error;
- if (prioWorkers) {
- if (virCondInit(&pool->prioCond) < 0)
- goto error;
-
- if (virThreadPoolExpand(pool, prioWorkers, true) < 0)
- goto error;
- }
+ if (virThreadPoolExpand(pool, prioWorkers, true) < 0)
+ goto error;
return pool;
@@ -268,7 +265,6 @@ virThreadPoolNewFull(size_t minWorkers,
void virThreadPoolFree(virThreadPoolPtr pool)
{
virThreadPoolJobPtr job;
- bool priority = false;
if (!pool)
return;
@@ -277,10 +273,8 @@ void virThreadPoolFree(virThreadPoolPtr
pool->quit = true;
if (pool->nWorkers > 0)
virCondBroadcast(&pool->cond);
- if (pool->nPrioWorkers > 0) {
- priority = true;
+ if (pool->nPrioWorkers > 0)
virCondBroadcast(&pool->prioCond);
- }
while (pool->nWorkers > 0 || pool->nPrioWorkers > 0)
ignore_value(virCondWait(&pool->quit_cond, &pool->mutex));
@@ -295,10 +289,8 @@ void virThreadPoolFree(virThreadPoolPtr
virMutexDestroy(&pool->mutex);
virCondDestroy(&pool->quit_cond);
virCondDestroy(&pool->cond);
- if (priority) {
- VIR_FREE(pool->prioWorkers);
- virCondDestroy(&pool->prioCond);
- }
+ VIR_FREE(pool->prioWorkers);
+ virCondDestroy(&pool->prioCond);
VIR_FREE(pool);
}