Re: [PATCH] Fix leak of mutex attributes in POSIX threads impl

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

 



On 01/24/2011 08:35 AM, Daniel P. Berrange wrote:
> * src/util/threads-pthread.c: Fix mutex leak
> ---
>  src/util/threads-pthread.c |    8 ++++++--
>  1 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/src/util/threads-pthread.c b/src/util/threads-pthread.c
> index ea71589..f812045 100644
> --- a/src/util/threads-pthread.c
> +++ b/src/util/threads-pthread.c
> @@ -47,7 +47,9 @@ int virMutexInit(virMutexPtr m)
>      pthread_mutexattr_t attr;
>      pthread_mutexattr_init(&attr);
>      pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_NORMAL);
> -    if ((ret = pthread_mutex_init(&m->lock, &attr)) != 0) {
> +    ret = pthread_mutex_init(&m->lock, &attr);
> +    pthread_mutexattr_destroy(&attr);
> +    if (ret != 0) {

ACK.  However, since we reuse the same attributes, would it be more
efficient to statically create a static pthread_mutexattr_t once, and
reuse it, rather than constantly recreating it on every call?

-- 
Eric Blake   eblake@xxxxxxxxxx    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP 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]