Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Step:15-SP4
libvirt.19372
255437ee-add-threadpool-funcs.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 255437ee-add-threadpool-funcs.patch of Package libvirt.19372
commit 255437eeb710d8135136af11b37ceae674d483ce Author: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com> Date: Thu Jul 9 10:58:02 2020 +0300 util: add stop/drain functions to thread pool Stop just send signal for threads to exit when they finish with current task. Drain waits when all threads will finish. Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com> Index: libvirt-5.1.0/src/libvirt_private.syms =================================================================== --- libvirt-5.1.0.orig/src/libvirt_private.syms +++ libvirt-5.1.0/src/libvirt_private.syms @@ -3062,6 +3062,7 @@ virThreadJobSetWorker; # util/virthreadpool.h +virThreadPoolDrain; virThreadPoolFree; virThreadPoolGetCurrentWorkers; virThreadPoolGetFreeWorkers; @@ -3072,6 +3073,7 @@ virThreadPoolGetPriorityWorkers; virThreadPoolNewFull; virThreadPoolSendJob; virThreadPoolSetParameters; +virThreadPoolStop; # util/virtime.h Index: libvirt-5.1.0/src/util/virthreadpool.c =================================================================== --- libvirt-5.1.0.orig/src/util/virthreadpool.c +++ libvirt-5.1.0/src/util/virthreadpool.c @@ -262,19 +262,27 @@ virThreadPoolNewFull(size_t minWorkers, } -void virThreadPoolFree(virThreadPoolPtr pool) -{ - virThreadPoolJobPtr job; - if (!pool) +static void +virThreadPoolStopLocked(virThreadPoolPtr pool) +{ + if (pool->quit) return; - virMutexLock(&pool->mutex); pool->quit = true; if (pool->nWorkers > 0) virCondBroadcast(&pool->cond); if (pool->nPrioWorkers > 0) virCondBroadcast(&pool->prioCond); +} + + +static void +virThreadPoolDrainLocked(virThreadPoolPtr pool) +{ + virThreadPoolJobPtr job; + + virThreadPoolStopLocked(pool); while (pool->nWorkers > 0 || pool->nPrioWorkers > 0) ignore_value(virCondWait(&pool->quit_cond, &pool->mutex)); @@ -283,6 +291,15 @@ void virThreadPoolFree(virThreadPoolPtr pool->jobList.head = pool->jobList.head->next; VIR_FREE(job); } +} + +void virThreadPoolFree(virThreadPoolPtr pool) +{ + if (!pool) + return; + + virMutexLock(&pool->mutex); + virThreadPoolDrainLocked(pool); VIR_FREE(pool->workers); virMutexUnlock(&pool->mutex); @@ -469,3 +486,19 @@ virThreadPoolSetParameters(virThreadPool virMutexUnlock(&pool->mutex); return -1; } + +void +virThreadPoolStop(virThreadPoolPtr pool) +{ + virMutexLock(&pool->mutex); + virThreadPoolStopLocked(pool); + virMutexUnlock(&pool->mutex); +} + +void +virThreadPoolDrain(virThreadPoolPtr pool) +{ + virMutexLock(&pool->mutex); + virThreadPoolDrainLocked(pool); + virMutexUnlock(&pool->mutex); +} Index: libvirt-5.1.0/src/util/virthreadpool.h =================================================================== --- libvirt-5.1.0.orig/src/util/virthreadpool.h +++ libvirt-5.1.0/src/util/virthreadpool.h @@ -58,4 +58,7 @@ int virThreadPoolSetParameters(virThread long long int maxWorkers, long long int prioWorkers); +void virThreadPoolStop(virThreadPoolPtr pool); +void virThreadPoolDrain(virThreadPoolPtr pool); + #endif /* LIBVIRT_VIRTHREADPOOL_H */
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor