[libvirt] [PATCH 1/5] Add a read/write lock implementation
Laine Stump
laine at laine.org
Thu Jan 23 17:05:03 UTC 2014
On 01/23/2014 03:46 PM, Daniel P. Berrange wrote:
> On Thu, Jan 23, 2014 at 03:22:53PM +0200, Laine Stump wrote:
>> On 01/23/2014 02:37 PM, Daniel P. Berrange wrote:
>>> Add virRWLock backed up by a POSIX rwlock primitive
>>>
>>> Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
>>> ---
>>> 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(+)
>>>
>>> diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
>>> index d1a58f9..eb91693 100644
>>> --- a/src/libvirt_private.syms
>>> +++ b/src/libvirt_private.syms
>>> @@ -1816,6 +1816,11 @@ virMutexInitRecursive;
>>> virMutexLock;
>>> virMutexUnlock;
>>> virOnce;
>>> +virRWLockInit;
>>> +virRWLockDestroy;
>>> +virRWLockRead;
>>> +virRWLockWrite;
>>> +virRWLockUnlock;
>> These are out of order.
>>
>>> virThreadCancel;
>>> virThreadCreate;
>>> virThreadID;
>>> diff --git a/src/util/virthread.h b/src/util/virthread.h
>>> index 84d3bdc..7015d60 100644
>>> --- a/src/util/virthread.h
>>> +++ b/src/util/virthread.h
>>> @@ -28,6 +28,9 @@
>>> typedef struct virMutex virMutex;
>>> typedef virMutex *virMutexPtr;
>>>
>>> +typedef struct virRWLock virRWLock;
>>> +typedef virRWLock *virRWLockPtr;
>>> +
>>> typedef struct virCond virCond;
>>> typedef virCond *virCondPtr;
>>>
>>> @@ -89,6 +92,13 @@ void virMutexLock(virMutexPtr m);
>>> void virMutexUnlock(virMutexPtr m);
>>>
>>>
>>> +int virRWLockInit(virRWLockPtr m) ATTRIBUTE_RETURN_CHECK;
>>> +void virRWLockDestroy(virRWLockPtr m);
>>> +
>>> +void virRWLockRead(virRWLockPtr m);
>>> +void virRWLockWrite(virRWLockPtr m);
>>> +void virRWLockUnlock(virRWLockPtr m);
>>> +
>> I was about to predict a build failure on Windows since you haven't
>> defined these functions in virthreadwin32.c, but then realized you
>> aren't yet calling them from anywhere, so the build will complete just fine.
>>
>> It would reduce code motion a bit to swap this patch with patch 2, but
>> functionally there's no difference.
> FYI the reason I did it in this order, is to make it easier to
> backport to the stable branches. eg on the stable branches I'd
> want to skip patch 2, since that's going to require a gnulib
> update too.
Aha. Totally worth it then!
More information about the libvir-list
mailing list