[asterisk-dev] [Code Review]: Add ability to clone ao2 containers.

rmudgett reviewboard at asterisk.org
Fri Feb 24 17:18:10 CST 2012



> On Feb. 24, 2012, 5:01 p.m., Kevin Fleming wrote:
> > /trunk/main/astobj2.c, lines 1067-1069
> > <https://reviewboard.asterisk.org/r/1746/diff/3/?file=24789#file24789line1067>
> >
> >     I must be misunderstanding. Why do we need to lock 'clone' at all, since this function holds the only reference to it? If we do need to lock it, why do we need to do so *only* when we don't need to lock the original container?

It gets the clone container in the expected locked state by ao2_container_dup().  For mutex locked containers, this is not really necessary.  However, when RWLOCKs are added, this really must be locked or the RWLOCK status checking and promotion code in the container would be messed up.


> On Feb. 24, 2012, 5:01 p.m., Kevin Fleming wrote:
> > /trunk/include/asterisk/astobj2.h, lines 792-793
> > <https://reviewboard.asterisk.org/r/1746/diff/3/?file=24788#file24788line792>
> >
> >     But even in this state the dest container should be in a usable state, and can be cleaned up using the normal methods, correct?

That is correct.  The clone container just does not have all of the objects of the src container.

How should I reword the note to better convey this?


- rmudgett


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/1746/#review5638
-----------------------------------------------------------


On Feb. 24, 2012, 4:50 p.m., rmudgett wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/1746/
> -----------------------------------------------------------
> 
> (Updated Feb. 24, 2012, 4:50 p.m.)
> 
> 
> Review request for Asterisk Developers.
> 
> 
> Summary
> -------
> 
> Occasionally there is a need to put all objects in one container also into another container.
> 
> Some reasons you might need to do this:
> 1) You need to reconfigure a container.   You would do this by creating a new container with the new configuration and ao2_container_dup the old container into it.  Then replace the old container with the new.  Then destroy the old container.
> 
> 2) You need the contents of a container to remain stable while operating on all of the objects.  You would do this by creating a cloned container of the original with ao2_container_clone.  The cloned container is a snapshot of the objects at the time of the cloning.  When done, just destroy the cloned container.
> 
> 
> Diffs
> -----
> 
>   /trunk/tests/test_astobj2.c 356735 
>   /trunk/include/asterisk/astobj2.h 356735 
>   /trunk/main/astobj2.c 356735 
> 
> Diff: https://reviewboard.asterisk.org/r/1746/diff
> 
> 
> Testing
> -------
> 
> Added unit testing code to test the new ao2_container_clone and ao2_container_dup functions.
> 
> Tests still pass.
> 
> 
> Thanks,
> 
> rmudgett
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20120224/5534829e/attachment-0001.htm>


More information about the asterisk-dev mailing list