Re: [PATCH 1/5] Add a read/write lock implementation

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

 



On 01/23/2014 05:37 AM, Daniel P. Berrange wrote:
> Add virRWLock backed up by a POSIX rwlock primitive
> 
> Signed-off-by: Daniel P. Berrange <berrange@xxxxxxxxxx>
> ---
>  src/libvirt_private.syms    |  5 +++++
>  src/util/virthread.h        | 10 ++++++++++
>  src/util/virthreadpthread.c | 31 +++++++++++++++++++++++++++++++
>  src/util/virthreadpthread.h |  4 ++++
>  4 files changed, 50 insertions(+)
> 

> +int virRWLockInit(virRWLockPtr m)
> +{
> +    if (pthread_rwlock_init(&m->lock, NULL) != 0) {
> +        errno = EINVAL;

Wouldn't this be better as:

int rc = pthread_rwlock_init(&m->lock, NULL);
if (rc) {
    errno = rc;
    return -1;
}
return 0;

so that we aren't clobbering non-EINVAL errors?


> +void virRWLockDestroy(virRWLockPtr m)
> +{
> +    pthread_rwlock_destroy(&m->lock);
> +}
> +
> +
> +void virRWLockRead(virRWLockPtr m)
> +{
> +    pthread_rwlock_rdlock(&m->lock);

Worth a VIR_DEBUG on failure of these functions, to help diagnose
incorrect usage?

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
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]