From 613674112ec87342f55a7b21c322be8034648802 Mon Sep 17 00:00:00 2001 From: sy <342482341@qq.com> Date: Sun, 1 May 2022 10:56:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=86=85=E5=AD=98=E6=B3=84?= =?UTF-8?q?=E6=BC=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libice/src/ice-checklist.c | 12 +++++++++--- libice/src/stun-request.c | 4 ++++ libice/test/ice-transport.c | 4 +++- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/libice/src/ice-checklist.c b/libice/src/ice-checklist.c index 9441ac6..d3237c1 100644 --- a/libice/src/ice-checklist.c +++ b/libice/src/ice-checklist.c @@ -149,9 +149,9 @@ int ice_checklist_reset(struct ice_checklist_t* l, struct ice_stream_t* stream, stun_timer_stop(l->timer); l->conclude = 0; l->state = ICE_CHECKLIST_FROZEN; - darray_clear(&l->valids); - darray_clear(&l->trigger); - ice_candidate_components_clear(&l->components); // reset components + darray_free(&l->valids); + darray_free(&l->trigger); + ice_candidate_components_free(&l->components); for (r = i = 0; i < ice_candidates_count(locals); i++) { @@ -515,6 +515,9 @@ static void ice_checklist_ontimer(void* param) { // timer next-tick ice_checklist_addref(l); + if (l->timer) + stun_timer_stop(l->timer); + l->timer = stun_timer_start(ICE_TIMER_INTERVAL * ice_agent_active_checklist_count(l->ice), ice_checklist_ontimer, l); } @@ -589,6 +592,9 @@ int ice_checklist_start(struct ice_checklist_t* l, int first) // start timer assert(NULL == l->timer); ice_checklist_addref(l); + if (l->timer) + stun_timer_stop(l->timer); + l->timer = stun_timer_start(ICE_TIMER_INTERVAL * ice_agent_active_checklist_count(l->ice), ice_checklist_ontimer, l); return 0; } diff --git a/libice/src/stun-request.c b/libice/src/stun-request.c index 7447c75..4b1223e 100644 --- a/libice/src/stun-request.c +++ b/libice/src/stun-request.c @@ -142,6 +142,8 @@ static void stun_request_ontimer(void* param) if (req->elapsed > req->timeout) req->interval = req->timeout + req->interval - req->elapsed; // 11000 = STUN_TIMEOUT - (500 + 1500 + 3500 + 7500 + 15500) + if (l->timer) + stun_timer_stop(req->timer); req->timer = stun_timer_start(req->interval, stun_request_ontimer, req); if (req->timer) { @@ -182,6 +184,8 @@ int stun_request_send(struct stun_agent_t* stun, struct stun_request_t* req) stun_request_addref(req); req->elapsed = 0; req->interval = STUN_RETRANSMISSION_INTERVAL_MIN; + if (l->timer) + stun_timer_stop(req->timer); req->timer = stun_timer_start(STUN_RETRANSMISSION_INTERVAL_MIN, stun_request_ontimer, req); } locker_unlock(&req->locker); diff --git a/libice/test/ice-transport.c b/libice/test/ice-transport.c index 8b88c54..0b082e0 100644 --- a/libice/test/ice-transport.c +++ b/libice/test/ice-transport.c @@ -583,5 +583,7 @@ void* stun_timer_start(int ms, void(*ontimer)(void* param), void* param) int stun_timer_stop(void* timer) { - return aio_timeout_stop((struct aio_timeout_t*)timer); + int ret = aio_timeout_stop((struct aio_timeout_t*)timer); + free(timer); + return ret; }