[asterisk-dev] [asterisk-commits] russell: trunk r90351 - in /trunk: ./ apps/ channels/ include/asterisk/ main/

Luigi Rizzo rizzo at icir.org
Fri Nov 30 14:08:54 CST 2007

On Fri, Nov 30, 2007 at 07:34:48PM -0000, SVN commits to the Asterisk project wrote:
> Author: russell
> Date: Fri Nov 30 13:34:47 2007
> New Revision: 90351
> URL: http://svn.digium.com/view/asterisk?view=rev&rev=90351
> Log:
> Merged revisions 90348 via svnmerge from 
> https://origsvn.digium.com/svn/asterisk/branches/1.4
> ........
> r90348 | russell | 2007-11-30 13:26:04 -0600 (Fri, 30 Nov 2007) | 8 lines
> Change the behavior of ao2_link().  Previously, in inherited a reference.
> Now, it automatically increases the reference count to reflect the reference
> that is now held by the container.
> This was done to be more consistent with ao2_unlink(), which automatically
> releases the reference held by the container.  It also makes it so it is
> no longer possible for a pointer to be invalid after ao2_link() returns.

Ok, i think this is a reasonable decision on the grounds of the additional
robustness it gives - we shouldn't see anymore things like

	ao2_link(queues, q);

where q was invalid after the ao2_link.

For the records, the reason we made ao2_link() inherit the reference
was that we expected it to be the normal case: create an object, fill it up
appropriately, and then put it into a container and be done with it.
I have to admit that, at least judging from this commit, our assumption
was true only by a very small margin, and in any case the robustness
implications are more important


More information about the asterisk-dev mailing list