Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复内存泄漏问题 #35

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions libice/src/ice-checklist.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++)
{
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -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;
}
Expand Down
4 changes: 4 additions & 0 deletions libice/src/stun-request.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion libice/test/ice-transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}