[libvirt] [PATCH] fixed bug:if expand thread pool, will lose some one

Di Wei dwlinuxkernel at 163.com
Thu Jan 11 15:30:41 UTC 2018


---
 src/util/virthreadpool.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/util/virthreadpool.c b/src/util/virthreadpool.c
index 10f2bd2..0983ee2 100644
--- a/src/util/virthreadpool.c
+++ b/src/util/virthreadpool.c
@@ -186,6 +186,7 @@ virThreadPoolExpand(virThreadPoolPtr pool, size_t gain, bool priority)
     size_t *curWorkers = priority ? &pool->nPrioWorkers : &pool->nWorkers;
     size_t i = 0;
     struct virThreadPoolWorkerData *data = NULL;
+    size_t oldNWorkers = *curWorkers;
 
     if (VIR_EXPAND_N(*workers, *curWorkers, gain) < 0)
         return -1;
@@ -198,7 +199,7 @@ virThreadPoolExpand(virThreadPoolPtr pool, size_t gain, bool priority)
         data->cond = priority ? &pool->prioCond : &pool->cond;
         data->priority = priority;
 
-        if (virThreadCreateFull(&(*workers)[i],
+        if (virThreadCreateFull(&(*workers)[i + oldNWorkers],
                                 false,
                                 virThreadPoolWorker,
                                 pool->jobFuncName,
-- 
2.9.3





More information about the libvir-list mailing list