[Libvir] [PATCH] avoid virsh hang due to missing virDomainFree(dom) call
Daniel P. Berrange
berrange at redhat.com
Wed Jan 30 18:21:42 UTC 2008
On Wed, Jan 30, 2008 at 07:00:30PM +0100, Jim Meyering wrote:
> "Daniel P. Berrange" <berrange at redhat.com> wrote:
> >
> > Not, its a bug in virUnrefDomain/Network - it calls mutex_lock() twice
> > in one codepath, instead of calling unlock().
> >
> > Of course your patch to avoid the memory leak is still needed - so ACK
> > to that, but the locking flaw needs this patch:
> >
> > Index: src/hash.c
> > ===================================================================
> > RCS file: /data/cvs/libvirt/src/hash.c,v
> > retrieving revision 1.29
> > diff -u -p -r1.29 hash.c
> > --- src/hash.c 29 Jan 2008 18:15:54 -0000 1.29
> > +++ src/hash.c 30 Jan 2008 17:42:32 -0000
> > @@ -881,7 +881,7 @@ virUnrefDomain(virDomainPtr domain) {
> > return (0);
> > }
> >
> > - pthread_mutex_lock(&domain->conn->lock);
> > + pthread_mutex_unlock(&domain->conn->lock);
> > return (refs);
> > }
> >
> > @@ -1013,7 +1013,7 @@ virUnrefNetwork(virNetworkPtr network) {
> > return (0);
> > }
> >
> > - pthread_mutex_lock(&network->conn->lock);
> > + pthread_mutex_unlock(&network->conn->lock);
> > return (refs);
> > }
>
> Oh! Two locks in a row.
> Amazing that such a problem wasn't exposed sooner.
Well I only committed this flaw last week, so not much time to expose it.
Fixed in CVS now.
Dan.
--
|=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=|
|=- Perl modules: http://search.cpan.org/~danberr/ -=|
|=- Projects: http://freshmeat.net/~danielpb/ -=|
|=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|
More information about the libvir-list
mailing list