[asterisk-dev] [Code Review]: Convert ast_rtp_codecs to using astobj2 internally for payloads
Joshua Colp
reviewboard at asterisk.org
Thu Jul 19 06:10:27 CDT 2012
> On July 18, 2012, 3:58 p.m., Mark Michelson wrote:
> > /trunk/main/rtp_engine.c, lines 625-628
> > <https://reviewboard.asterisk.org/r/2052/diff/1/?file=30360#file30360line625>
> >
> > You could just do:
> >
> > ao2_find(codecs->payloads, &payload, OBJ_KEY | OBJ_NOLOCK | OBJ_NODATA | OBJ_UNLINK);
> >
> >
Changed.
> On July 18, 2012, 3:58 p.m., Mark Michelson wrote:
> > /trunk/main/rtp_engine.c, lines 667-675
> > <https://reviewboard.asterisk.org/r/2052/diff/1/?file=30360#file30360line667>
> >
> > The use of "format" here appears unsafe to me.
> >
> > Since format is pointing to data within an ao2 object, it's possible that the ao2 object can get destroyed, thus leaving format pointing to freed memory.
In practice this is actually safe. The user of this API has to protect the contents because the API itself doesn't do it and the user can't store the returned format because it is only valid for the duration of the time they protect the contents, this was even true in the old implementation.
- Joshua
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviewboard.asterisk.org/r/2052/#review6724
-----------------------------------------------------------
On July 19, 2012, 6:10 a.m., Joshua Colp wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/2052/
> -----------------------------------------------------------
>
> (Updated July 19, 2012, 6:10 a.m.)
>
>
> Review request for Asterisk Developers.
>
>
> Summary
> -------
>
> While doing the media attribute work I needed to increase the available space for attribute information but this has caused stack space usage to increase. While I have reduced it some there is still quite a bit of memory being consumed. To help with this I have converted ast_rtp_codecs to use astobj2 internally for storing payload information. The only memory used will be that of payloads present in the structure, and not a huge array containing every possible one. For all cases this should reduce memory consumption considerably and for most cases should reduce it to an amount lower than before attribute support was even added.
>
>
> Diffs
> -----
>
> /trunk/channels/chan_motif.c 370182
> /trunk/channels/chan_sip.c 370182
> /trunk/include/asterisk/rtp_engine.h 370182
> /trunk/main/rtp_engine.c 370182
> /trunk/res/res_rtp_asterisk.c 370182
>
> Diff: https://reviewboard.asterisk.org/r/2052/diff
>
>
> Testing
> -------
>
> Done my own testing with calls to ensure they still work properly, and also ran the testsuite.
>
>
> Thanks,
>
> Joshua
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20120719/6582b010/attachment.htm>
More information about the asterisk-dev
mailing list