virThreadPoolFree: Set n(Prio)Workers after the pool is locked
In 78839da0 I am trying to join the worker threads. However, I can't sipmly reuse pool->nWorkers (same applies for pool->nPrioWorkers), because of the following flow that is currently implemented: 1) the main thread executing virThreadPoolFree sets pool->quit = true, wakes up all the workers and wait on pool->quit_cond. 2) A worker is woken up and see quit request. It immediately jumps of the while() loop and decrements pool->nWorkers (or pool->nPrioWorkers in case of priority worker). The last thread signalizes pool->quit_cond. 3) Main thread is woken up, with both pool->nWorkers and pool->nPrioWorkers being zero. So there's a need to copy the original value of worker thread counts into local variables. However, these need to set *after* the check for pool being NULL (dereferencing a NULL is no no). And for safety they can be set right after the pool is locked. Reported-by: NJohn Ferlan <jferlan@redhat.com> Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
Showing
想要评论请 注册 或 登录