[DataChannelController] Don't fire events from within a loop
Removes a couple of temporary workarounds added in this CL: https://webrtc-review.googlesource.com/c/src/+/297981 Bug: webrtc:15004 Change-Id: I93e025725be1db56528726cc9f79740e366b8a68 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/298200 Reviewed-by: Henrik Boström <hbos@webrtc.org> Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org> Cr-Commit-Position: refs/heads/main@{#39602}
This commit is contained in:
parent
75990b9a8f
commit
dc90a9c583
@ -100,11 +100,9 @@ void DataChannelController::OnDataReceived(
|
||||
RTC_DCHECK_RUN_ON(signaling_thread());
|
||||
// TODO(bugs.webrtc.org/11547): The data being received should be
|
||||
// delivered on the network thread.
|
||||
auto copy = sctp_data_channels_;
|
||||
for (const auto& channel : copy) {
|
||||
if (channel->id() == channel_id)
|
||||
channel->OnDataReceived(type, buffer);
|
||||
}
|
||||
auto it = FindChannel(StreamId(channel_id));
|
||||
if (it != sctp_data_channels_.end())
|
||||
(*it)->OnDataReceived(type, buffer);
|
||||
}));
|
||||
}
|
||||
|
||||
@ -114,11 +112,9 @@ void DataChannelController::OnChannelClosing(int channel_id) {
|
||||
SafeTask(signaling_safety_.flag(), [this, channel_id] {
|
||||
RTC_DCHECK_RUN_ON(signaling_thread());
|
||||
// TODO(bugs.webrtc.org/11547): Should run on the network thread.
|
||||
auto copy = sctp_data_channels_;
|
||||
for (const auto& channel : copy) {
|
||||
if (channel->id() == channel_id)
|
||||
channel->OnClosingProcedureStartedRemotely();
|
||||
}
|
||||
auto it = FindChannel(StreamId(channel_id));
|
||||
if (it != sctp_data_channels_.end())
|
||||
(*it)->OnClosingProcedureStartedRemotely();
|
||||
}));
|
||||
}
|
||||
|
||||
@ -127,10 +123,7 @@ void DataChannelController::OnChannelClosed(int channel_id) {
|
||||
signaling_thread()->PostTask(
|
||||
SafeTask(signaling_safety_.flag(), [this, channel_id] {
|
||||
RTC_DCHECK_RUN_ON(signaling_thread());
|
||||
auto it = absl::c_find_if(sctp_data_channels_, [&](const auto& c) {
|
||||
return c->id() == channel_id;
|
||||
});
|
||||
|
||||
auto it = FindChannel(StreamId(channel_id));
|
||||
// Remove the channel from our list, close it and free up resources.
|
||||
if (it != sctp_data_channels_.end()) {
|
||||
rtc::scoped_refptr<SctpDataChannel> channel = std::move(*it);
|
||||
@ -418,6 +411,13 @@ void DataChannelController::NotifyDataChannelsOfTransportCreated() {
|
||||
}));
|
||||
}
|
||||
|
||||
std::vector<rtc::scoped_refptr<SctpDataChannel>>::iterator
|
||||
DataChannelController::FindChannel(StreamId stream_id) {
|
||||
RTC_DCHECK_RUN_ON(signaling_thread());
|
||||
return absl::c_find_if(sctp_data_channels_,
|
||||
[&](const auto& c) { return c->sid() == stream_id; });
|
||||
}
|
||||
|
||||
rtc::Thread* DataChannelController::network_thread() const {
|
||||
return pc_->network_thread();
|
||||
}
|
||||
|
||||
@ -134,6 +134,9 @@ class DataChannelController : public SctpDataChannelControllerInterface,
|
||||
// (calls OnTransportChannelCreated on the signaling thread).
|
||||
void NotifyDataChannelsOfTransportCreated();
|
||||
|
||||
std::vector<rtc::scoped_refptr<SctpDataChannel>>::iterator FindChannel(
|
||||
StreamId stream_id);
|
||||
|
||||
rtc::Thread* network_thread() const;
|
||||
rtc::Thread* signaling_thread() const;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user