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(a)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