Re: [PATCH 1/2] virObjectUnref: Set pointer to NULL on dispose

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 08.11.2013 06:27, Daniel P. Berrange wrote:
> On Thu, Nov 07, 2013 at 11:39:27AM +0100, Michal Privoznik wrote:
>> Similarly to VIR_FREE() we can set the pointer passed to virObjectUnref
>> to NULL in case of disposing the object. However, to avoid overwriting
>> nearly thousands line of code, the virObjectUnref is turned into a macro
>> which passes the address of pointer and calls virObjectUnrefInternal
>> (the modified version of original virObjectUnref).
> 
> I have to say I'm not really liking this, and your impl is not race
> free since you're not atomically updating the point.
> 
> Daniel
> 


I don't think I follow you there. AFAIU, the whole 'if' body is executed
exactly once iff obj->refs is zero after decrement. And I don't see how
can I possibly race with others.

If two threads calls virObjectUnref on the very same object with
refcount = 1, do you expect them both to have the *ptr = NULL?

Michal

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]