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

--- 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

Sorry for that the information is not obvious. I hope that the information below is sufficient.If need more information,let me know. Bug’s consequence: Assume that there is a threadpool like [ thread 1 | thread 2 | thread 3 ] After expanding this threadpool with virThreadPoolExpand(ptr,1,priority), it should be [ thread 1 | thread 2 | thread 3 | thread 4 ] but the result will be [ thread 4 | thread 2 | thread 3 | NULL ] the first one thread 1 is lost.
在 2018年1月12日,下午5:19,Peter Krempa <pkrempa@redhat.com> 写道:
On Thu, Jan 11, 2018 at 23:30:41 +0800, Di Wei wrote:
---
Could you please provide more information on when this is happening and what the consequences are? It's really not obvious from the summary and it's required to be part of the commit message.
participants (3)
-
Di Wei
-
diwei
-
Peter Krempa