提交 d1a366be 编写于 作者: M Michal Privoznik

Threadpool: Initialize new dynamic workers

Although we were initializing worker threads during pool creating,
we missed this during virThreadPoolSendJob. This bug led to segmenation
fault as worker thread free() given argument.
上级 a6e2ef73
......@@ -286,6 +286,7 @@ int virThreadPoolSendJob(virThreadPoolPtr pool,
void *jobData)
{
virThreadPoolJobPtr job;
struct virThreadPoolWorkerData *data = NULL;
virMutexLock(&pool->mutex);
if (pool->quit)
......@@ -298,10 +299,20 @@ int virThreadPoolSendJob(virThreadPoolPtr pool,
goto error;
}
if (VIR_ALLOC(data) < 0) {
pool->nWorkers--;
virReportOOMError();
goto error;
}
data->pool = pool;
data->cond = &pool->cond;
if (virThreadCreate(&pool->workers[pool->nWorkers - 1],
true,
virThreadPoolWorker,
pool) < 0) {
data) < 0) {
VIR_FREE(data);
pool->nWorkers--;
goto error;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册