From 53aef9f03429c8d0906b1bb4faf2811e52285799 Mon Sep 17 00:00:00 2001 From: Jeff Peeler Date: Fri, 6 Jun 2008 18:02:12 +0000 Subject: [PATCH] Merged revisions 120906 via svnmerge from https://origsvn.digium.com/svn/asterisk/trunk ................ r120906 | jpeeler | 2008-06-06 12:50:05 -0500 (Fri, 06 Jun 2008) | 16 lines Merged revisions 120863,120885 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r120863 | jpeeler | 2008-06-06 10:33:15 -0500 (Fri, 06 Jun 2008) | 3 lines This fixes a crash when LOW_MEMORY is turned on. Two allocations of the ast_rtp struct that were previously allocated on the stack have been modified to use thread local storage instead. ........ r120885 | jpeeler | 2008-06-06 11:39:20 -0500 (Fri, 06 Jun 2008) | 2 lines Correction to commmit 120863, make sure proper destructor function is called as well define two thread storage local variables. ........ ................ git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.0@120907 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- channels/chan_sip.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/channels/chan_sip.c b/channels/chan_sip.c index d9e2a10226..dd8ab765cf 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -1586,6 +1586,12 @@ static void temp_pvt_cleanup(void *); /*! \brief A per-thread temporary pvt structure */ AST_THREADSTORAGE_CUSTOM(ts_temp_pvt, temp_pvt_init, temp_pvt_cleanup); +static void ts_ast_rtp_destroy(void *); + +AST_THREADSTORAGE_CUSTOM(ts_audio_rtp, NULL, ts_ast_rtp_destroy); +AST_THREADSTORAGE_CUSTOM(ts_video_rtp, NULL, ts_ast_rtp_destroy); +AST_THREADSTORAGE_CUSTOM(ts_text_rtp, NULL, ts_ast_rtp_destroy); + /*! \brief Authentication list for realm authentication * \todo Move the sip_auth list to AST_LIST */ static struct sip_auth *authl = NULL; @@ -6342,17 +6348,29 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req, int t38action } /* Initialize the temporary RTP structures we use to evaluate the offer from the peer */ +#ifdef LOW_MEMORY + newaudiortp = ast_threadstorage_get(&ts_audio_rtp, ast_rtp_alloc_size()); +#else newaudiortp = alloca(ast_rtp_alloc_size()); +#endif memset(newaudiortp, 0, ast_rtp_alloc_size()); ast_rtp_new_init(newaudiortp); ast_rtp_pt_clear(newaudiortp); +#ifdef LOW_MEMORY + newvideortp = ast_threadstorage_get(&ts_video_rtp, ast_rtp_alloc_size()); +#else newvideortp = alloca(ast_rtp_alloc_size()); +#endif memset(newvideortp, 0, ast_rtp_alloc_size()); ast_rtp_new_init(newvideortp); ast_rtp_pt_clear(newvideortp); +#ifdef LOW_MEMORY + newtextrtp = ast_threadstorage_get(&ts_text_rtp, ast_rtp_alloc_size()); +#else newtextrtp = alloca(ast_rtp_alloc_size()); +#endif memset(newtextrtp, 0, ast_rtp_alloc_size()); ast_rtp_new_init(newtextrtp); ast_rtp_pt_clear(newtextrtp); @@ -6991,6 +7009,11 @@ static int process_sdp(struct sip_pvt *p, struct sip_request *req, int t38action return 0; } +static void ts_ast_rtp_destroy(void *data) +{ + struct ast_rtp *tmp = data; + ast_rtp_destroy(tmp); +} /*! \brief Add header to SIP message */ static int add_header(struct sip_request *req, const char *var, const char *value)