mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 15:27:47 +00:00
virThreadPoolFree: Join worker threads
Even though currently we are freeing the pool of worker threads at the daemon very end, nothing holds us back in joining the worker threads. Moreover, we avoid leaks like this: ==26697== 1,680 bytes in 5 blocks are possibly lost in loss record 913 of 942 ==26697== at 0x4C2BDE4: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==26697== by 0x4011131: allocate_dtv (in /lib64/ld-2.16.so) ==26697== by 0x401176D: _dl_allocate_tls (in /lib64/ld-2.16.so) ==26697== by 0x8499602: pthread_create@@GLIBC_2.2.5 (in /lib64/libpthread-2.16.so) ==26697== by 0x52F53E9: virThreadCreate (virthreadpthread.c:188) ==26697== by 0x52F5D4F: virThreadPoolNew (virthreadpool.c:221) ==26697== by 0x53F30DB: virNetServerNew (virnetserver.c:377) ==26697== by 0x11C6ED: main (libvirtd.c:1366) Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
81fae6b95c
commit
78839da0bb
@ -241,6 +241,9 @@ void virThreadPoolFree(virThreadPoolPtr pool)
|
||||
{
|
||||
virThreadPoolJobPtr job;
|
||||
bool priority = false;
|
||||
size_t i;
|
||||
size_t nWorkers = pool->nWorkers;
|
||||
size_t nPrioWorkers = pool->nPrioWorkers;
|
||||
|
||||
if (!pool)
|
||||
return;
|
||||
@ -262,6 +265,12 @@ void virThreadPoolFree(virThreadPoolPtr pool)
|
||||
VIR_FREE(job);
|
||||
}
|
||||
|
||||
for (i = 0; i < nWorkers; i++)
|
||||
virThreadJoin(&pool->workers[i]);
|
||||
|
||||
for (i = 0; i < nPrioWorkers; i++)
|
||||
virThreadJoin(&pool->prioWorkers[i]);
|
||||
|
||||
VIR_FREE(pool->workers);
|
||||
virMutexUnlock(&pool->mutex);
|
||||
virMutexDestroy(&pool->mutex);
|
||||
|
Loading…
Reference in New Issue
Block a user