Commit 93b5d3cb authored by Fabrice Bellet's avatar Fabrice Bellet Committed by Olivier Crête

conncheck: optimize pending checks pruning

We use the property that the conncheck list is ordered by
pairs priorities, so we don't have to iterate twice.
parent 0c142b36
...@@ -3122,35 +3122,32 @@ int conn_check_send (NiceAgent *agent, CandidateCheckPair *pair) ...@@ -3122,35 +3122,32 @@ int conn_check_send (NiceAgent *agent, CandidateCheckPair *pair)
static guint priv_prune_pending_checks (NiceAgent *agent, NiceStream *stream, guint component_id) static guint priv_prune_pending_checks (NiceAgent *agent, NiceStream *stream, guint component_id)
{ {
GSList *i; GSList *i;
guint64 highest_nominated_priority = 0;
guint in_progress = 0; guint in_progress = 0;
gboolean found_nominated = FALSE;
gchar prio1[NICE_CANDIDATE_PAIR_PRIORITY_MAX_SIZE]; gchar prio1[NICE_CANDIDATE_PAIR_PRIORITY_MAX_SIZE];
gchar prio2[NICE_CANDIDATE_PAIR_PRIORITY_MAX_SIZE]; gchar prio2[NICE_CANDIDATE_PAIR_PRIORITY_MAX_SIZE];
nice_debug ("Agent %p: Finding highest priority for component %d", nice_debug ("Agent %p: Finding highest priority for component %d",
agent, component_id); agent, component_id);
for (i = stream->conncheck_list; i; i = i->next) {
CandidateCheckPair *p = i->data;
if (p->component_id == component_id && p->valid == TRUE &&
p->nominated == TRUE) {
if (p->priority > highest_nominated_priority) {
highest_nominated_priority = p->priority;
}
}
}
nice_candidate_pair_priority_to_string (highest_nominated_priority, prio1);
nice_debug ("Agent %p: Pruning pending checks. Highest nominated priority "
"is %s.", agent, prio1);
/* step: cancel all FROZEN and WAITING pairs for the component */
i = stream->conncheck_list; i = stream->conncheck_list;
while (i) { while (i) {
CandidateCheckPair *p = i->data; CandidateCheckPair *p = i->data;
GSList *next = i->next; GSList *next = i->next;
if (p->component_id == component_id) { if (p->component_id != component_id) {
i = next;
continue;
}
if (p->valid && p->nominated && !found_nominated) {
found_nominated = TRUE;
nice_candidate_pair_priority_to_string (p->priority, prio1);
nice_debug ("Agent %p: Pruning pending checks. Highest nominated "
"priority is %s.", agent, prio1);
}
/* step: cancel all FROZEN and WAITING pairs for the component */
if (p->state == NICE_CHECK_FROZEN || p->state == NICE_CHECK_WAITING) { if (p->state == NICE_CHECK_FROZEN || p->state == NICE_CHECK_WAITING) {
nice_debug ("Agent %p : pair %p removed.", agent, p); nice_debug ("Agent %p : pair %p removed.", agent, p);
candidate_check_pair_free (agent, p); candidate_check_pair_free (agent, p);
...@@ -3159,10 +3156,9 @@ static guint priv_prune_pending_checks (NiceAgent *agent, NiceStream *stream, gu ...@@ -3159,10 +3156,9 @@ static guint priv_prune_pending_checks (NiceAgent *agent, NiceStream *stream, gu
/* note: a SHOULD level req. in ICE 8.1.2. "Updating States" (ID-19) */ /* note: a SHOULD level req. in ICE 8.1.2. "Updating States" (ID-19) */
else if (p->state == NICE_CHECK_IN_PROGRESS) { else if (p->state == NICE_CHECK_IN_PROGRESS) {
if (p->priority < highest_nominated_priority) { if (found_nominated) {
p->retransmit = FALSE; p->retransmit = FALSE;
nice_debug ("Agent %p : pair %p will not be retransmitted.", nice_debug ("Agent %p : pair %p will not be retransmitted.", agent, p);
agent, p);
} else { } else {
/* We must keep the higher priority pairs running because if a udp /* We must keep the higher priority pairs running because if a udp
* packet was lost, we might end up using a bad candidate */ * packet was lost, we might end up using a bad candidate */
...@@ -3173,7 +3169,6 @@ static guint priv_prune_pending_checks (NiceAgent *agent, NiceStream *stream, gu ...@@ -3173,7 +3169,6 @@ static guint priv_prune_pending_checks (NiceAgent *agent, NiceStream *stream, gu
in_progress++; in_progress++;
} }
} }
}
i = next; i = next;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment