[libvirt] [PATCH v2 1/4] Add a read/write lock implementation
Eric Blake
eblake at redhat.com
Mon Jan 27 22:45:13 UTC 2014
On 01/27/2014 10:18 AM, Daniel P. Berrange wrote:
> Add virRWLock backed up by a POSIX rwlock primitive
>
> Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
> ---
> +int virRWLockInit(virRWLockPtr m)
> +{
> + if (pthread_rwlock_init(&m->lock, NULL) != 0) {
> + errno = EINVAL;
> + return -1;
My concern from v1 still stands - this blindly overwrites non-EINVAL
errors, and better would be:
int rc = pthread_rwlock_init(&m->lock, NULL);
if (rc) {
errno = rc;
return -1;
}
> +void virRWLockDestroy(virRWLockPtr m)
> +{
> + pthread_rwlock_destroy(&m->lock);
Likewise, it might be nice to add VIR_DEBUG messages when discarding a
non-zero result, as a way to diagnose the programmer errors that caused
that situation.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 604 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20140127/dc17a9b3/attachment-0001.sig>
More information about the libvir-list
mailing list