Re: [libvirt] [PATCH v3 01/14] Add recursive locks

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

 



On Tue, Mar 23, 2010 at 10:54:07AM -0400, stefanb@xxxxxxxxxx wrote:
> This patch adds recursive locks necessary due to the processing of
> network filter XML that can reference other network filters, including
> references that cause looks. Loops in the XML are prevented but their
> detection requires recursive locks.
> 
> Signed-off-by: Stefan Berger <stefanb@xxxxxxxxxx>
> 
> ---
>  src/util/threads-pthread.c |   13 +++++++++++++
>  src/util/threads-win32.c   |    5 +++++
>  src/util/threads.h         |    1 +
>  3 files changed, 19 insertions(+)
> 
> Index: libvirt-acl/src/util/threads-pthread.c
> ===================================================================
> --- libvirt-acl.orig/src/util/threads-pthread.c
> +++ libvirt-acl/src/util/threads-pthread.c
> @@ -46,6 +46,19 @@ int virMutexInit(virMutexPtr m)
>      return 0;
>  }
>  
> +int virMutexInitRecursive(virMutexPtr m)
> +{
> +    int ret;
> +    pthread_mutexattr_t attr;
> +    pthread_mutexattr_init(&attr);
> +    pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
> +    if ((ret = pthread_mutex_init(&m->lock, &attr)) != 0) {
> +        errno = ret;
> +        return -1;
> +    }
> +    return 0;
> +}
> +
>  void virMutexDestroy(virMutexPtr m)
>  {
>      pthread_mutex_destroy(&m->lock);
> Index: libvirt-acl/src/util/threads.h
> ===================================================================
> --- libvirt-acl.orig/src/util/threads.h
> +++ libvirt-acl/src/util/threads.h
> @@ -38,6 +38,7 @@ int virThreadInitialize(void) ATTRIBUTE_
>  void virThreadOnExit(void);
>  
>  int virMutexInit(virMutexPtr m) ATTRIBUTE_RETURN_CHECK;
> +int virMutexInitRecursive(virMutexPtr m) ATTRIBUTE_RETURN_CHECK;
>  void virMutexDestroy(virMutexPtr m);
>  
>  void virMutexLock(virMutexPtr m);
> Index: libvirt-acl/src/util/threads-win32.c
> ===================================================================
> --- libvirt-acl.orig/src/util/threads-win32.c
> +++ libvirt-acl/src/util/threads-win32.c
> @@ -69,6 +69,11 @@ void virThreadOnExit(void)
>  
>  int virMutexInit(virMutexPtr m)
>  {
> +    virMutexInitRecursive(m);
> +}
> +
> +int virMutexInitRecursive(virMutexPtr m)
> +{
>      if (!(m->lock = CreateMutex(NULL, FALSE, NULL))) {
>          errno = ESRCH;
>          return -1;
> 


ACK


Daniel
-- 
|: Red Hat, Engineering, London    -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :|
|: http://autobuild.org        -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|

--
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]