talloc_reference() (again)

Stefan (metze) Metzmacher metze at samba.org
Wed Oct 16 22:03:10 MDT 2013


Am 17.10.2013 03:54, schrieb Andrew Bartlett:
> (resend with correct sender address)
> 
> On Wed, 2013-10-16 at 07:42 -0400, Simo wrote:
> 
>> +1 the evilness of talloc_reference is that an arbitrary *user* of the
>> memory can change the semantics for *all* others, this is a recipe for
>> disaster and the reason this API must be discouraged and eventually
>> dumped.
> 
> This is perhaps the best explanation of the issues.  The graph issue is 
> important, but the behaviour change on talloc_free() is the real hard part of this problem. 
> 
> This is why I think the idea proposed (but never taken anywhere) of 
> a talloc_may_reference() is the best that I've seen for handling 
> objects that need to be reference counted, either internally or 
> because they are exposed to another reference-based system, such 
> as python.  The proposal is that this call would then set referenced
> semantics on an object, regardless of if it was actually referenced,
> keeping behaviour like 'must talloc_unlink()' consistent. 
> 
> That discussion was here:
> https://lists.samba.org/archive/samba-technical/2011-October/080045.html
> 
> Alternately, metze suggested some patterns, which I think are the same that Volker was referring to, to make talloc_reference less of an issue here:
> https://lists.samba.org/archive/samba-technical/2011-October/080102.html
> 

I think we should do both and still avoid it at all as much as we can.

metze


More information about the samba-technical mailing list