Retrieve and store the hostname only once so multiple threads do not potentially...
authorJoshua Colp <jcolp@digium.com>
Wed, 2 Oct 2013 14:13:55 +0000 (14:13 +0000)
committerJoshua Colp <jcolp@digium.com>
Wed, 2 Oct 2013 14:13:55 +0000 (14:13 +0000)
........

Merged revisions 400245 from http://svn.asterisk.org/svn/asterisk/branches/12

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@400246 65c4cc65-6c06-0410-ace0-fbb531ad65f3

res/res_pjsip_session.c

index 54e03f5..965f66b 100644 (file)
@@ -48,6 +48,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);
 static void handle_incoming_response(struct ast_sip_session *session, pjsip_rx_data *rdata);
@@ -1991,7 +1994,7 @@ static struct pjmedia_sdp_session *create_local_sdp(pjsip_inv_session *inv, stru
        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 @@ static int load_module(void)
        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;
        }