diff --git a/daemon/call.c b/daemon/call.c index 88264ca54..316476f06 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -525,8 +525,6 @@ void call_timer(void *ptr) { kill_calls_timer(hlp.del_scheduled, NULL); kill_calls_timer(hlp.del_timeout, rtpe_config.b2b_url); - ice_slow_timer(); - struct timeval tv_stop; gettimeofday(&tv_stop, NULL); long long duration = timeval_diff(&tv_stop, &tv_start); diff --git a/daemon/ice.c b/daemon/ice.c index 25a40e9e8..4fd9b12fd 100644 --- a/daemon/ice.c +++ b/daemon/ice.c @@ -762,7 +762,18 @@ void ice_slow_timer(void) { fragments_cleanup(false); } +/** + * Separate thread for for ice slow timer functionality. + */ +void ice_slow_timer_iterator(void * dummy) { + while (!rtpe_shutdown) { + ice_slow_timer(); + thread_cancel_enable(); + usleep(1000000); /* sleep for 1 second in each iteration */ + thread_cancel_disable(); + } +} static void __fail_pair(struct ice_candidate_pair *pair) { ilogs(ice, LOG_DEBUG, "Setting ICE candidate pair "PAIR_FORMAT" as failed", PAIR_FMT(pair)); diff --git a/daemon/main.c b/daemon/main.c index 974c9239c..8cbdf7c48 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -1358,6 +1358,10 @@ int main(int argc, char **argv) { thread_create_detach_prio(kernel_stats_updater_iterator, NULL, rtpe_config.idle_scheduling, rtpe_config.idle_priority, "kernel stats updater"); + /* separate thread for ice slow timer functionality */ + thread_create_detach_prio(ice_slow_timer_iterator, NULL, rtpe_config.idle_scheduling, + rtpe_config.idle_priority, "ice slow timer"); + if (!is_addr_unspecified(&rtpe_config.redis_ep.address) && initial_rtpe_config.redis_delete_async) thread_create_detach(redis_delete_async_loop, NULL, "redis async"); diff --git a/include/ice.h b/include/ice.h index e8d5036f0..175e7947b 100644 --- a/include/ice.h +++ b/include/ice.h @@ -176,7 +176,7 @@ bool trickle_ice_update(struct ng_buffer *ngbuf, struct call *call, struct sdp_n void ice_slow_timer(void); - +void ice_slow_timer_iterator(void * dummy); #include "call.h" diff --git a/t/test-stats.c b/t/test-stats.c index dbe9f8fc7..a0dfb3ebe 100644 --- a/t/test-stats.c +++ b/t/test-stats.c @@ -3233,6 +3233,7 @@ int main(void) { call_timer(NULL); stats_counters_calc_rate(&rtpe_stats, 150000000, &rtpe_stats_intv, &rtpe_stats_rate); stats_rate_min_max(&rtpe_rate_graphite_min_max, &rtpe_stats_rate); + ice_slow_timer(); RTPE_STATS_ADD(ng_commands[NGC_OFFER], 100); rtpe_now.tv_sec += 2; @@ -3241,6 +3242,7 @@ int main(void) { call_timer(NULL); stats_counters_calc_rate(&rtpe_stats, 2000000, &rtpe_stats_intv, &rtpe_stats_rate); stats_rate_min_max(&rtpe_rate_graphite_min_max, &rtpe_stats_rate); + ice_slow_timer(); // timer run time interval increased rtpe_now.tv_sec += 5; @@ -3249,6 +3251,7 @@ int main(void) { call_timer(NULL); stats_counters_calc_rate(&rtpe_stats, 5000000, &rtpe_stats_intv, &rtpe_stats_rate); stats_rate_min_max(&rtpe_rate_graphite_min_max, &rtpe_stats_rate); + ice_slow_timer(); graph_str = print_graphite_data(); assert_g_string_eq(graph_str,