Skip to content
Closed
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
10 changes: 10 additions & 0 deletions src/sctp_transport/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,12 +212,22 @@ impl RTCSctpTransport {
}

async fn accept_data_channels(param: AcceptDataChannelParams) {
let dcs = param.data_channels.lock().await;
let mut existing_data_channels = Vec::new();
for dc in dcs.iter() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also one idea I just had is to modify DataChannel::accept to accept a reference to a list of existing data channels. That way we won't need to clone all of them, just the one with matching identifier.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 will make a PR to update there.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if let Some(dc) = dc.data_channel.lock().await.clone() {
let dc2 = dc.as_ref().clone();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the second clone? if it's an already cloned object

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, good question! The clone() should be to_owned() instead.

existing_data_channels.push(dc2);
}
}

loop {
let dc = tokio::select! {
_ = param.notify_rx.notified() => break,
result = DataChannel::accept(
&param.sctp_association,
data::data_channel::Config::default(),
existing_data_channels.to_owned(),
) => {
match result {
Ok(dc) => dc,
Expand Down