[asterisk-commits] jpeeler: trunk r120906 - in /trunk: ./ channels/chan_sip.c main/features.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jun 6 12:50:06 CDT 2008


Author: jpeeler
Date: Fri Jun  6 12:50:05 2008
New Revision: 120906

URL: http://svn.digium.com/view/asterisk?view=rev&rev=120906
Log:
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.

........

Modified:
    trunk/   (props changed)
    trunk/channels/chan_sip.c
    trunk/main/features.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Modified: trunk/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_sip.c?view=diff&rev=120906&r1=120905&r2=120906
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Fri Jun  6 12:50:05 2008
@@ -1723,6 +1723,12 @@
 /*! \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;
@@ -6685,17 +6691,29 @@
 	}
 
 	/* 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);
@@ -7364,6 +7382,11 @@
 	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)

Modified: trunk/main/features.c
URL: http://svn.digium.com/view/asterisk/trunk/main/features.c?view=diff&rev=120906&r1=120905&r2=120906
==============================================================================
--- trunk/main/features.c (original)
+++ trunk/main/features.c Fri Jun  6 12:50:05 2008
@@ -464,11 +464,12 @@
 	struct parkeduser *pu;
 	int i, x = -1, parking_range;
 	struct ast_context *con;
-	const char *parkinglotname;
+	const char *parkinglotname = NULL;
 	const char *parkingexten;
 	struct ast_parkinglot *parkinglot = NULL;
 	
-	parkinglotname = findparkinglotname(peer);
+	if (peer)
+		parkinglotname = findparkinglotname(peer);
 
 	if (parkinglotname) {
 		if (option_debug)




More information about the asterisk-commits mailing list