提交 e981607e 编写于 作者: E Erik Skultety

util: Use a mutex when retrieving threadpool data

So far, the values the affected getters retrieve are static, i.e. there's no
way of changing them during runtime. But admin interface will later enable
not only getting but changing them as well. So to prevent phenomenons like
torn reads or concurrent reads and writes of unaligned values, use mutual
exclusion when getting these values (writes do, understandably, use them
already).
Signed-off-by: NErik Skultety <eskultet@redhat.com>
上级 79685175
......@@ -286,17 +286,35 @@ void virThreadPoolFree(virThreadPoolPtr pool)
size_t virThreadPoolGetMinWorkers(virThreadPoolPtr pool)
{
return pool->minWorkers;
size_t ret;
virMutexLock(&pool->mutex);
ret = pool->minWorkers;
virMutexUnlock(&pool->mutex);
return ret;
}
size_t virThreadPoolGetMaxWorkers(virThreadPoolPtr pool)
{
return pool->maxWorkers;
size_t ret;
virMutexLock(&pool->mutex);
ret = pool->maxWorkers;
virMutexUnlock(&pool->mutex);
return ret;
}
size_t virThreadPoolGetPriorityWorkers(virThreadPoolPtr pool)
{
return pool->nPrioWorkers;
size_t ret;
virMutexLock(&pool->mutex);
ret = pool->nPrioWorkers;
virMutexUnlock(&pool->mutex);
return ret;
}
/*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册