From 8aa52c36a9c680e906357093b8f450f5b77bdb19 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Thu, 3 Nov 2016 11:11:04 +0100 Subject: [PATCH] Prevent useless DNS resolution of STUN server. --- coreapi/nat_policy.c | 3 +-- tester/call_single_tester.c | 19 ++++++++++++------- tester/call_video_tester.c | 3 +++ 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/coreapi/nat_policy.c b/coreapi/nat_policy.c index 2d0826ef9..a16bc8104 100644 --- a/coreapi/nat_policy.c +++ b/coreapi/nat_policy.c @@ -185,7 +185,6 @@ void linphone_nat_policy_set_stun_server(LinphoneNatPolicy *policy, const char * } if (new_stun_server != NULL) { policy->stun_server = new_stun_server; - linphone_nat_policy_resolve_stun_server(policy); } } @@ -250,7 +249,7 @@ const struct addrinfo * linphone_nat_policy_get_stun_server_addrinfo(LinphoneNat * - if no cached value exists, block for a short time; this case must be unprobable because the resolution will be asked each * time the stun server value is changed. */ - if (linphone_nat_policy_stun_server_activated(policy)) { + if (linphone_nat_policy_stun_server_activated(policy) && (policy->stun_addrinfo == NULL)) { int wait_ms = 0; int wait_limit = 1000; linphone_nat_policy_resolve_stun_server(policy); diff --git a/tester/call_single_tester.c b/tester/call_single_tester.c index 116d00009..7042346cf 100644 --- a/tester/call_single_tester.c +++ b/tester/call_single_tester.c @@ -1325,39 +1325,41 @@ static void ice_added_by_reinvite(void){ LinphoneCallParams *params; LinphoneCall *c; bool_t call_ok; - + lp_config_set_int(linphone_core_get_config(marie->lc), "net", "allow_late_ice", 1); lp_config_set_int(linphone_core_get_config(pauline->lc), "net", "allow_late_ice", 1); BC_ASSERT_TRUE((call_ok=call(pauline,marie))); if (!call_ok) goto end; liblinphone_tester_check_rtcp(marie,pauline); - + /*enable ICE on both ends*/ pol = linphone_core_get_nat_policy(marie->lc); linphone_nat_policy_enable_ice(pol, TRUE); linphone_nat_policy_enable_stun(pol, TRUE); linphone_core_set_nat_policy(marie->lc, pol); - + pol = linphone_core_get_nat_policy(pauline->lc); linphone_nat_policy_enable_ice(pol, TRUE); linphone_nat_policy_enable_stun(pol, TRUE); linphone_core_set_nat_policy(pauline->lc, pol); - + + linphone_core_manager_wait_for_stun_resolution(marie); + linphone_core_manager_wait_for_stun_resolution(pauline); + c = linphone_core_get_current_call(marie->lc); params = linphone_core_create_call_params(marie->lc, c); linphone_core_update_call(marie->lc, c, params); linphone_call_params_destroy(params); - BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallUpdatedByRemote,1)); /*wait for the ICE reINVITE*/ BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,3)); BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,3)); BC_ASSERT_TRUE(check_ice(marie, pauline, LinphoneIceStateHostConnection)); - + end_call(pauline, marie); - + end: linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); @@ -1800,6 +1802,9 @@ static void audio_call_with_ice_no_matching_audio_codecs(void) { linphone_core_set_firewall_policy(marie->lc, LinphonePolicyUseIce); linphone_core_set_firewall_policy(pauline->lc, LinphonePolicyUseIce); + linphone_core_manager_wait_for_stun_resolution(marie); + linphone_core_manager_wait_for_stun_resolution(pauline); + out_call = linphone_core_invite_address(marie->lc, pauline->identity); linphone_call_ref(out_call); BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallOutgoingInit, 1)); diff --git a/tester/call_video_tester.c b/tester/call_video_tester.c index 62a19ae23..354a9b325 100644 --- a/tester/call_video_tester.c +++ b/tester/call_video_tester.c @@ -1092,6 +1092,9 @@ static void call_with_ice_video_and_rtt(void) { linphone_core_set_firewall_policy(marie->lc, LinphonePolicyUseIce); linphone_core_set_firewall_policy(pauline->lc, LinphonePolicyUseIce); + linphone_core_manager_wait_for_stun_resolution(marie); + linphone_core_manager_wait_for_stun_resolution(pauline); + linphone_core_set_audio_port(marie->lc, -1); linphone_core_set_video_port(marie->lc, -1); linphone_core_set_text_port(marie->lc, -1);