Re: [PATCH 4/6] virThreadPoolFree: Join worker threads

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Nov 14, 2013 at 10:51:14AM +0100, Michal Privoznik wrote:
> 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.
> 

s/daemon/daemon's/ ???

Unless the thread is blocked, right?  Not that it should happen, but
maybe adding a wrapper for pthread_timedjoin_np and using that (if
available) might be better?  Just an idea, I haven't thought that
through ;)

> Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
> ---
>  src/util/virthreadpool.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/src/util/virthreadpool.c b/src/util/virthreadpool.c
> index b1e2c0c..99f36ec 100644
> --- a/src/util/virthreadpool.c
> +++ b/src/util/virthreadpool.c
> @@ -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);
> -- 
> 1.8.3.2
> 
> --
> libvir-list mailing list
> libvir-list@xxxxxxxxxx
> https://www.redhat.com/mailman/listinfo/libvir-list

Attachment: signature.asc
Description: Digital signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]