[libvirt] [PATCH 5/5] Turn nwfilter conf update mutex into a read/write lock

Daniel P. Berrange berrange at redhat.com
Mon Jan 27 17:16:27 UTC 2014


On Thu, Jan 23, 2014 at 02:46:42PM -0500, Stefan Berger wrote:
> On 01/23/2014 07:37 AM, Daniel P. Berrange wrote:
> 
> >
> >@@ -3477,7 +3482,7 @@ int virNWFilterConfLayerInit(virDomainObjListIterator domUpdateCB,
> >
> >      initialized = true;
> >
> >-    if (virMutexInitRecursive(&updateMutex) < 0)
> >+    if (virRWLockInit(&updateLock) < 0)
> >          return -1;
> >
> 
> Obviously it was a recursive lock before. Now
> pthread_rwlock_wrlock() must not be called twice by the same thread.
> I am fine with the conversion below per se. The functions below are
> quite low-level now (close to virsh) that they are not called
> recursively. So from this perspective for this patch:

The write locks aren't ever acquired recursively, since they're only
held in top level functions. The read locks are still allowed to be
recursive so we're safe in that respect.

Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|




More information about the libvir-list mailing list