[asterisk-dev] [Code Review]: Audit of ao2_iterator_init() usage for v1.8

rmudgett reviewboard at asterisk.org
Fri Jan 27 10:07:02 CST 2012



> On Jan. 27, 2012, 9:26 a.m., Kevin Fleming wrote:
> > /branches/1.8/apps/app_queue.c, line 1401
> > <https://reviewboard.asterisk.org/r/1697/diff/1/?file=23665#file23665line1401>
> >
> >     What was the reasoning for moving this (and the other) 'unlock' operations?

Mostly construct/destruct symmetry.

Also when I am able to implement my astobj2 container enhancements, if you use the AO2_ITERATOR_DONTLOCK option flag you *must* keep the container locked for the entire iteration including the ao2_iterator_destroy.


> On Jan. 27, 2012, 9:26 a.m., Kevin Fleming wrote:
> > /branches/1.8/apps/app_queue.c, lines 6831-6833
> > <https://reviewboard.asterisk.org/r/1697/diff/1/?file=23665#file23665line6831>
> >
> >     How is this better?

In this particular instance it isn't much of an improvement.  However, I am seeing a lot of cases where indiscriminate initialization like this causes harm.  There are a few places fixed with this patch where that is the case.

For example:
void foo(struct ast_channel *chan)
{
  const char *name = chan->name;

  if (!chan) {
    return;
  }
  ...
}

This function will crash if chan is NULL even though it is supposedly checking for it.


- rmudgett


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


On Jan. 26, 2012, 8:03 p.m., rmudgett wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/1697/
> -----------------------------------------------------------
> 
> (Updated Jan. 26, 2012, 8:03 p.m.)
> 
> 
> Review request for Asterisk Developers and Mark Michelson.
> 
> 
> Summary
> -------
> 
> I audited the usage of the ao2_iterator_init() function in the v1.8 code base.
> 
> I checked that the iterator was destroyed and that the current iteration object reference was not leaked.
> 
> This patch fixes numerous reference leaks and missing ao2_iterator_destroy() calls as a result.
> 
> 
> Diffs
> -----
> 
>   /branches/1.8/apps/app_chanspy.c 352861 
>   /branches/1.8/apps/app_queue.c 352861 
>   /branches/1.8/channels/chan_iax2.c 352861 
>   /branches/1.8/channels/chan_sip.c 352861 
>   /branches/1.8/include/asterisk/indications.h 352861 
>   /branches/1.8/main/indications.c 352861 
>   /branches/1.8/main/pbx.c 352861 
>   /branches/1.8/main/taskprocessor.c 352861 
>   /branches/1.8/res/res_odbc.c 352861 
>   /branches/1.8/res/res_srtp.c 352861 
>   /branches/1.8/res/snmp/agent.c 352861 
> 
> Diff: https://reviewboard.asterisk.org/r/1697/diff
> 
> 
> Testing
> -------
> 
> It compiles. :)
> 
> 
> Thanks,
> 
> rmudgett
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20120127/10dc9379/attachment.htm>


More information about the asterisk-dev mailing list