[asterisk-commits] file: branch 12 r400245 - /branches/12/res/res_pjsip_session.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Oct 2 09:13:11 CDT 2013


Author: file
Date: Wed Oct  2 09:13:08 2013
New Revision: 400245

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=400245
Log:
Retrieve and store the hostname only once so multiple threads do not potentially initialize it at the same time.

Modified:
    branches/12/res/res_pjsip_session.c

Modified: branches/12/res/res_pjsip_session.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/res/res_pjsip_session.c?view=diff&rev=400245&r1=400244&r2=400245
==============================================================================
--- branches/12/res/res_pjsip_session.c (original)
+++ branches/12/res/res_pjsip_session.c Wed Oct  2 09:13:08 2013
@@ -47,6 +47,9 @@
 
 #define MOD_DATA_ON_RESPONSE "on_response"
 #define MOD_DATA_NAT_HOOK "nat_hook"
+
+/* Hostname used for origin line within SDP */
+static const pj_str_t *hostname;
 
 /* Some forward declarations */
 static void handle_incoming_request(struct ast_sip_session *session, pjsip_rx_data *rdata);
@@ -1991,7 +1994,7 @@
 	pj_strdup2(inv->pool, &local->origin.user, session->endpoint->media.sdpowner);
 	local->origin.net_type = STR_IN;
 	local->origin.addr_type = session->endpoint->media.rtp.ipv6 ? STR_IP6 : STR_IP4;
-	local->origin.addr = *pj_gethostname();
+	local->origin.addr = *hostname;
 	pj_strdup2(inv->pool, &local->name, session->endpoint->media.sdpsession);
 
 	/* Now let the handlers add streams of various types, pjmedia will automatically reorder the media streams for us */
@@ -2137,6 +2140,7 @@
 	pjsip_inv_usage_init(endpt, &inv_callback);
 	pjsip_100rel_init_module(endpt);
 	pjsip_timer_init_module(endpt);
+	hostname = pj_gethostname();
 	if (ast_sip_register_service(&session_module)) {
 		return AST_MODULE_LOAD_DECLINE;
 	}




More information about the asterisk-commits mailing list