From ec0a93b6322ec89bfe39502f0353b88cb87729fc Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Wed, 27 Aug 2014 12:03:59 +0200 Subject: [PATCH] prevent unnecessary lookup in pending auth list --- coreapi/bellesip_sal/sal_impl.c | 8 ++++++-- coreapi/bellesip_sal/sal_impl.h | 1 + tester/call_tester.c | 16 +++++++++------- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/coreapi/bellesip_sal/sal_impl.c b/coreapi/bellesip_sal/sal_impl.c index ab7714fa9..7c0901276 100644 --- a/coreapi/bellesip_sal/sal_impl.c +++ b/coreapi/bellesip_sal/sal_impl.c @@ -98,12 +98,16 @@ void sal_disable_logs() { void sal_add_pending_auth(Sal *sal, SalOp *op){ if (ms_list_find(sal->pending_auths,op)==NULL){ sal->pending_auths=ms_list_append(sal->pending_auths,op); + op->has_auth_pending=TRUE; } } void sal_remove_pending_auth(Sal *sal, SalOp *op){ - if (ms_list_find(sal->pending_auths,op)){ - sal->pending_auths=ms_list_remove(sal->pending_auths,op); + if (op->has_auth_pending){ + op->has_auth_pending=FALSE; + if (ms_list_find(sal->pending_auths,op)){ + sal->pending_auths=ms_list_remove(sal->pending_auths,op); + } } } diff --git a/coreapi/bellesip_sal/sal_impl.h b/coreapi/bellesip_sal/sal_impl.h index a20150de2..613c7b06e 100644 --- a/coreapi/bellesip_sal/sal_impl.h +++ b/coreapi/bellesip_sal/sal_impl.h @@ -102,6 +102,7 @@ struct SalOp{ bool_t sdp_offering; bool_t call_released; bool_t manual_refresher; + bool_t has_auth_pending; int auth_requests; /*number of auth requested for this op*/ }; diff --git a/tester/call_tester.c b/tester/call_tester.c index 47606b7a3..229ea536c 100644 --- a/tester/call_tester.c +++ b/tester/call_tester.c @@ -758,8 +758,8 @@ static bool_t check_ice(LinphoneCoreManager* caller, LinphoneCoreManager* callee LinphoneCall *c1,*c2; bool_t audio_success=FALSE; bool_t video_success=FALSE; - int i; bool_t video_enabled; + MSTimeSpec ts; c1=linphone_core_get_current_call(caller->lc); c2=linphone_core_get_current_call(callee->lc); @@ -772,7 +772,8 @@ static bool_t check_ice(LinphoneCoreManager* caller, LinphoneCoreManager* callee CU_ASSERT_EQUAL(linphone_call_params_video_enabled(linphone_call_get_current_params(c1)),linphone_call_params_video_enabled(linphone_call_get_current_params(c2))); video_enabled=linphone_call_params_video_enabled(linphone_call_get_current_params(c1)); - for (i=0;i<200;i++){ + liblinphone_tester_clock_start(&ts); + do{ if ((c1 != NULL) && (c2 != NULL)) { if (linphone_call_get_audio_stats(c1)->ice_state==state && linphone_call_get_audio_stats(c2)->ice_state==state ){ @@ -782,11 +783,12 @@ static bool_t check_ice(LinphoneCoreManager* caller, LinphoneCoreManager* callee linphone_core_iterate(caller->lc); linphone_core_iterate(callee->lc); } - ms_usleep(50000); - } + ms_usleep(20000); + }while(liblinphone_tester_clock_elapsed(&ts,10000)); if (video_enabled){ - for (i=0;i<200;i++){ + liblinphone_tester_clock_start(&ts); + do{ if ((c1 != NULL) && (c2 != NULL)) { if (linphone_call_get_video_stats(c1)->ice_state==state && linphone_call_get_video_stats(c2)->ice_state==state ){ @@ -796,8 +798,8 @@ static bool_t check_ice(LinphoneCoreManager* caller, LinphoneCoreManager* callee linphone_core_iterate(caller->lc); linphone_core_iterate(callee->lc); } - ms_usleep(50000); - } + ms_usleep(20000); + }while(liblinphone_tester_clock_elapsed(&ts,5000)); } /*make sure encryption mode are preserved*/