[libvirt] [PATCH 13/13] Turn virNetClient* into virObject instances

Eric Blake eblake at redhat.com
Tue Jul 17 20:36:18 UTC 2012


On 07/11/2012 07:35 AM, Daniel P. Berrange wrote:
> From: "Daniel P. Berrange" <berrange at redhat.com>
> 
> Make all the virNetClient* objects use virObject APIs for
> reference counting
> 
> Signed-off-by: Daniel P. Berrange <berrange at redhat.com>
> ---

> @@ -286,19 +294,22 @@ static virNetClientPtr virNetClientNew(virNetSocketPtr sock,

>  
> -    if (virMutexInit(&client->lock) < 0)
> +    if (virMutexInit(&client->lock) < 0) {
> +        VIR_FREE(client);
>          goto error;

Hmm - this discards the fact that client has a ref-count of 1, and thus
fails to poison that memory (one of the benefits of always going through
unref is that that poisoning helps detect use-after-free bugs).
Thankfully, though, there is no other allocated memory owned by 'client'
at this point in time, so skipping the dispose method is not technically
a leak; furthermore, since the dispose method tries to call
virMutexDestroy but we know the mutex failed to initialize, I think it's
the best we can do.  You made me think about this, but in the end I
agree it is right, even though it looks fishy.

ACK.  Overall, the series looks like a good improvement (anything that
can cause a net reduction in lines of code _and_ speed up execution with
fewer lock points all while remaining atomically correct is awesome); I
did point out some flaws through the series, and look forward to
reviewing v2 (or more likely, the interdiff between v1 and v2).

-- 
Eric Blake   eblake at 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: 620 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20120717/c9e1a045/attachment-0001.sig>


More information about the libvir-list mailing list