[asterisk-dev] [Code Review] 3689: Media format improvements: the great renaming + some cleanup

Corey Farrell reviewboard at asterisk.org
Wed Jul 2 02:55:48 CDT 2014


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


I did not look at any of chan_jingle, chan_h323, or chan_gtalk.


/team/group/media_formats-reviewed-trunk/include/asterisk/format_cap.h
<https://reviewboard.asterisk.org/r/3689/#comment22688>

    I think this procedure should be named ast_format_cap_append_by_type, to be the reverse of ast_format_cap_remove_by_type.
    
    The current ast_format_cap_add_by_type could be named ast_format_cap_append_cap_by_type?  In any case I think that should have the longer name since it's a more specific action.
    
    Sorry I didn't pick this up during the original email exchange.



/team/group/media_formats-reviewed-trunk/include/asterisk/frame.h
<https://reviewboard.asterisk.org/r/3689/#comment22691>

    This looks like temporary code I was considering that should not be done now. The idea was to move format from subclass, forcing a full system audit of references to the frames format.



/team/group/media_formats-reviewed-trunk/main/astobj2_container.c
<https://reviewboard.asterisk.org/r/3689/#comment22690>

    I feel about this the same as I do the astobj2.c change.  I think merges from trunk should be done in commits separate from actual media_formats work.  I think immediately after this change is committed would be a good time to update from trunk.  We can include r3698 in that merge.



/team/group/media_formats-reviewed-trunk/main/bridge.c
<https://reviewboard.asterisk.org/r/3689/#comment22689>

    I think ast_str should be ast_str_alloca'ed from here once instead of twice.



/team/group/media_formats-reviewed-trunk/main/format_cache.c
<https://reviewboard.asterisk.org/r/3689/#comment22687>

    As with other REF_DEBUG functions I feel we should accept a tag parameter, use S_OR.  



/team/group/media_formats-reviewed-trunk/main/format_cap.c
<https://reviewboard.asterisk.org/r/3689/#comment22681>

    This procedure accepts tag, so it should be passed to __ao2_alloc_debug.  Maybe S_OR(tag, "ast_format_cap_alloc") would be better?



/team/group/media_formats-reviewed-trunk/main/format_cap.c
<https://reviewboard.asterisk.org/r/3689/#comment22682>

    I'm against duplicating code.  I'd much rather this be moved to a static (inline?) function.



/team/group/media_formats-reviewed-trunk/main/format_cap.c
<https://reviewboard.asterisk.org/r/3689/#comment22683>

    Do we want to debug this?  framed seems like it belongs to format_cap.c.  I think maybe just ao2_t_alloc to pass the tag but use format_cap.c:185 as the file:line.  Additionally use ao2_ref for other manipulations of framed.



/team/group/media_formats-reviewed-trunk/main/format_cap.c
<https://reviewboard.asterisk.org/r/3689/#comment22684>

    Please S_OR for tag



/team/group/media_formats-reviewed-trunk/main/format_cap.c
<https://reviewboard.asterisk.org/r/3689/#comment22685>

    I think this ref is leaked.  You don't need a new reference, we already have one from the framed = ao2_alloc.
    
    Original (non-debug) procedure contains this error as well.  Again I'm against duplication of code, I think most of this should be moved to a function shared by the debug and non-debug versions.



/team/group/media_formats-reviewed-trunk/main/format_cap.c
<https://reviewboard.asterisk.org/r/3689/#comment22686>

    Maybe check if we've reached buf's limit?  Since most calls to this procedure use ast_str_alloca we could escape early if we're already full.  I feel like we should still return the string.  Assume that any caller which requires complete output will provide a malloc'ed ast_str or an alloca'ed one that is large enough.


- Corey Farrell


On July 1, 2014, 10:53 p.m., Matt Jordan wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviewboard.asterisk.org/r/3689/
> -----------------------------------------------------------
> 
> (Updated July 1, 2014, 10:53 p.m.)
> 
> 
> Review request for Asterisk Developers.
> 
> 
> Repository: Asterisk
> 
> 
> Description
> -------
> 
> This patch performs the renaming discussed on the asterisk-dev list [1]. As usual, as I was going through it some other cleanups occurred, and in order to make sure I didn't make memory leaks worse, some parts of Corey's memory leak cleanups made their way in as well.
> 
> [1] http://lists.digium.com/pipermail/asterisk-dev/2014-June/068133.html
> 
> The great renaming:
> 
>  * ast_format_cap_add             => ast_format_cap_append
>  * ast_format_cap_add_all_by_type => ast_format_cap_append_all_by_type
>  * ast_parse_allow_disallow       => ast_format_cap_update_by_allow_disallow
>  * ast_cap_remove_bytype          => ast_format_cap_remove_by_type
>  * ast_getformatname_multiple     => ast_format_cap_get_names, and now uses an ast_str ** instead of a char *buf/size_t len
>  * ast_format_sdp_generate        => ast_format_generate_sdp_fmtp
>  * ast_format_sdp_parse           => ast_format_parse_sdp_fmtp
> 
> Functions removed:
>  * ast_format_compatibility_get_original_id - no longer used
> 
> Note that chan_h323, chan_gtalk, and chan_jingle did not get all of the re-namings (particularly ast_getformatname_multiple => ast_format_cap_get_names), and will not compile with this patch. These modules should be removed, per the discussion on the -dev list.
> 
> Functions that support REF_DEBUG:
>  * ast_format_cap_alloc
>  * ast_format_cap_append
>  * ast_format_cache_get
> 
> Memory leak cleanups (many of which came from Corey's patches):
>  * Channel technology struct capabilities leak their format capabilities on off nominal exit paths (chan_motif, chan_pjsip, chan_unistim, chan_skinny)
>  * Format capabilities leak in chan_pjsip_new nominal path
>  * Leak of nativeformats format_cap in nominal path of channel.c's ast_channel_alloc
>  * Leak of format_cap in channel.c's set_format
>  * Leak of format_cap in channel.c's ast_request
>  * Usage of ao2_replace in translate.c to avoid overwriting a ref
>  * Clean up of frame format cache in RTP instance in res_rtp_asterisk destructor
> 
> Unit tests
>  * Remove test for ast_getformatname_multiple, add test for ast_format_cap_get_names
> 
> 
> Diffs
> -----
> 
>   /team/group/media_formats-reviewed-trunk/tests/test_voicemail_api.c 417740 
>   /team/group/media_formats-reviewed-trunk/tests/test_format_cap.c 417740 
>   /team/group/media_formats-reviewed-trunk/tests/test_format_api.c 417740 
>   /team/group/media_formats-reviewed-trunk/tests/test_core_format.c 417740 
>   /team/group/media_formats-reviewed-trunk/tests/test_config.c 417740 
>   /team/group/media_formats-reviewed-trunk/res/res_stasis_snoop.c 417740 
>   /team/group/media_formats-reviewed-trunk/res/res_stasis.c 417740 
>   /team/group/media_formats-reviewed-trunk/res/res_rtp_asterisk.c 417740 
>   /team/group/media_formats-reviewed-trunk/res/res_pjsip_sdp_rtp.c 417740 
>   /team/group/media_formats-reviewed-trunk/res/res_pjsip/pjsip_configuration.c 417740 
>   /team/group/media_formats-reviewed-trunk/res/res_clioriginate.c 417740 
>   /team/group/media_formats-reviewed-trunk/res/res_calendar.c 417740 
>   /team/group/media_formats-reviewed-trunk/res/res_agi.c 417740 
>   /team/group/media_formats-reviewed-trunk/res/parking/parking_applications.c 417740 
>   /team/group/media_formats-reviewed-trunk/res/ari/resource_channels.c 417740 
>   /team/group/media_formats-reviewed-trunk/res/ari/resource_bridges.c 417740 
>   /team/group/media_formats-reviewed-trunk/pbx/pbx_spool.c 417740 
>   /team/group/media_formats-reviewed-trunk/main/translate.c 417740 
>   /team/group/media_formats-reviewed-trunk/main/sorcery.c 417740 
>   /team/group/media_formats-reviewed-trunk/main/rtp_engine.c 417740 
>   /team/group/media_formats-reviewed-trunk/main/media_index.c 417740 
>   /team/group/media_formats-reviewed-trunk/main/manager.c 417740 
>   /team/group/media_formats-reviewed-trunk/main/frame.c 417740 
>   /team/group/media_formats-reviewed-trunk/main/format_compatibility.c 417740 
>   /team/group/media_formats-reviewed-trunk/main/format_cap.c 417740 
>   /team/group/media_formats-reviewed-trunk/main/format_cache.c 417740 
>   /team/group/media_formats-reviewed-trunk/main/format.c 417740 
>   /team/group/media_formats-reviewed-trunk/main/file.c 417740 
>   /team/group/media_formats-reviewed-trunk/main/dial.c 417740 
>   /team/group/media_formats-reviewed-trunk/main/core_local.c 417740 
>   /team/group/media_formats-reviewed-trunk/main/config_options.c 417740 
>   /team/group/media_formats-reviewed-trunk/main/cli.c 417740 
>   /team/group/media_formats-reviewed-trunk/main/channel.c 417740 
>   /team/group/media_formats-reviewed-trunk/main/ccss.c 417740 
>   /team/group/media_formats-reviewed-trunk/main/bridge_basic.c 417740 
>   /team/group/media_formats-reviewed-trunk/main/bridge.c 417740 
>   /team/group/media_formats-reviewed-trunk/main/astobj2_container.c 417740 
>   /team/group/media_formats-reviewed-trunk/include/asterisk/slin.h 417740 
>   /team/group/media_formats-reviewed-trunk/include/asterisk/rtp_engine.h 417740 
>   /team/group/media_formats-reviewed-trunk/include/asterisk/frame.h 417740 
>   /team/group/media_formats-reviewed-trunk/include/asterisk/format_compatibility.h 417740 
>   /team/group/media_formats-reviewed-trunk/include/asterisk/format_cap.h 417740 
>   /team/group/media_formats-reviewed-trunk/include/asterisk/format_cache.h 417740 
>   /team/group/media_formats-reviewed-trunk/include/asterisk/format.h 417740 
>   /team/group/media_formats-reviewed-trunk/funcs/func_channel.c 417740 
>   /team/group/media_formats-reviewed-trunk/codecs/ex_ulaw.h 417740 
>   /team/group/media_formats-reviewed-trunk/codecs/ex_gsm.h 417740 
>   /team/group/media_formats-reviewed-trunk/codecs/ex_alaw.h 417740 
>   /team/group/media_formats-reviewed-trunk/codecs/ex_adpcm.h 417740 
>   /team/group/media_formats-reviewed-trunk/channels/pjsip/dialplan_functions.c 417740 
>   /team/group/media_formats-reviewed-trunk/channels/dahdi/bridge_native_dahdi.c 417740 
>   /team/group/media_formats-reviewed-trunk/channels/chan_unistim.c 417740 
>   /team/group/media_formats-reviewed-trunk/channels/chan_skinny.c 417740 
>   /team/group/media_formats-reviewed-trunk/channels/chan_sip.c 417740 
>   /team/group/media_formats-reviewed-trunk/channels/chan_pjsip.c 417740 
>   /team/group/media_formats-reviewed-trunk/channels/chan_phone.c 417740 
>   /team/group/media_formats-reviewed-trunk/channels/chan_oss.c 417740 
>   /team/group/media_formats-reviewed-trunk/channels/chan_nbs.c 417740 
>   /team/group/media_formats-reviewed-trunk/channels/chan_multicast_rtp.c 417740 
>   /team/group/media_formats-reviewed-trunk/channels/chan_motif.c 417740 
>   /team/group/media_formats-reviewed-trunk/channels/chan_misdn.c 417740 
>   /team/group/media_formats-reviewed-trunk/channels/chan_mgcp.c 417740 
>   /team/group/media_formats-reviewed-trunk/channels/chan_jingle.c 417740 
>   /team/group/media_formats-reviewed-trunk/channels/chan_iax2.c 417740 
>   /team/group/media_formats-reviewed-trunk/channels/chan_h323.c 417740 
>   /team/group/media_formats-reviewed-trunk/channels/chan_gtalk.c 417740 
>   /team/group/media_formats-reviewed-trunk/channels/chan_dahdi.c 417740 
>   /team/group/media_formats-reviewed-trunk/channels/chan_console.c 417740 
>   /team/group/media_formats-reviewed-trunk/channels/chan_bridge_media.c 417740 
>   /team/group/media_formats-reviewed-trunk/channels/chan_alsa.c 417740 
>   /team/group/media_formats-reviewed-trunk/bridges/bridge_softmix.c 417740 
>   /team/group/media_formats-reviewed-trunk/bridges/bridge_simple.c 417740 
>   /team/group/media_formats-reviewed-trunk/bridges/bridge_native_rtp.c 417740 
>   /team/group/media_formats-reviewed-trunk/bridges/bridge_holding.c 417740 
>   /team/group/media_formats-reviewed-trunk/apps/confbridge/conf_chan_record.c 417740 
>   /team/group/media_formats-reviewed-trunk/apps/app_voicemail.c 417740 
>   /team/group/media_formats-reviewed-trunk/apps/app_originate.c 417740 
>   /team/group/media_formats-reviewed-trunk/apps/app_meetme.c 417740 
>   /team/group/media_formats-reviewed-trunk/apps/app_dumpchan.c 417740 
>   /team/group/media_formats-reviewed-trunk/apps/app_confbridge.c 417740 
>   /team/group/media_formats-reviewed-trunk/addons/chan_ooh323.c 417740 
>   /team/group/media_formats-reviewed-trunk/addons/chan_mobile.c 417740 
> 
> Diff: https://reviewboard.asterisk.org/r/3689/diff/
> 
> 
> Testing
> -------
> 
> Negotiation using PJSIP still works.
> 
> The most prevalent memory leak that still occurs happens when a statically allocated frame ref bumps a format. This happens a lot when generating translator tables, and in various other places as well.
> 
> 
> Thanks,
> 
> Matt Jordan
> 
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20140702/a8c315e8/attachment-0001.html>


More information about the asterisk-dev mailing list