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

ice: Fix USE-CANDIDATE in controlled agent #647

Merged
Merged
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
15 changes: 10 additions & 5 deletions ice/src/agent/agent_selector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,12 @@ impl ControlledSelector for AgentInternal {
p.state
.store(CandidatePairState::Succeeded as u8, Ordering::SeqCst);
log::trace!("Found valid candidate pair: {}", p);

if p.nominate_on_binding_success.load(Ordering::SeqCst)
&& self.agent_conn.get_selected_pair().is_none()
{
self.set_selected_pair(Some(Arc::clone(&p))).await;
}
} else {
// This shouldn't happen
log::error!("Success response from invalid candidate pair");
Expand Down Expand Up @@ -524,7 +530,6 @@ impl ControlledSelector for AgentInternal {
if self.agent_conn.get_selected_pair().is_none() {
self.set_selected_pair(Some(Arc::clone(&p))).await;
}
self.send_binding_success(m, local, remote).await;
} else {
// If the received Binding request triggered a new check to be
// enqueued in the triggered-check queue (Section 7.3.1.4), once the
Expand All @@ -534,12 +539,12 @@ impl ControlledSelector for AgentInternal {
// MUST remove the candidate pair from the valid list, set the
// candidate pair state to Failed, and set the checklist state to
// Failed.
self.ping_candidate(local, remote).await;
p.nominate_on_binding_success.store(true, Ordering::SeqCst);
}
} else {
self.send_binding_success(m, local, remote).await;
self.ping_candidate(local, remote).await;
}

self.send_binding_success(m, local, remote).await;
self.ping_candidate(local, remote).await;
}
}
}
3 changes: 3 additions & 0 deletions ice/src/candidate/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ pub struct CandidatePair {
pub(crate) binding_request_count: AtomicU16,
pub(crate) state: AtomicU8, // convert it to CandidatePairState,
pub(crate) nominated: AtomicBool,
pub(crate) nominate_on_binding_success: AtomicBool,
}

impl Default for CandidatePair {
Expand All @@ -245,6 +246,7 @@ impl Default for CandidatePair {
state: AtomicU8::new(CandidatePairState::Waiting as u8),
binding_request_count: AtomicU16::new(0),
nominated: AtomicBool::new(false),
nominate_on_binding_success: AtomicBool::new(false),
}
}
}
Expand Down Expand Up @@ -297,6 +299,7 @@ impl CandidatePair {
state: AtomicU8::new(CandidatePairState::Waiting as u8),
binding_request_count: AtomicU16::new(0),
nominated: AtomicBool::new(false),
nominate_on_binding_success: AtomicBool::new(false),
}
}

Expand Down
Loading