Commit 4f62c7bb authored by Harald Alvestrand's avatar Harald Alvestrand Committed by Chromium LUCI CQ

Iterate more carefully over DTLS transports at close

Ensure that even if the set of DTLS transports is modified during
callbacks called from close, the process will be well-defined.

Bug: chromium:1167357
Change-Id: I712280e7382a647027912178156127831b437f75
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2639893Reviewed-by: default avatarHenrik Boström <hbos@chromium.org>
Commit-Queue: Harald Alvestrand <hta@chromium.org>
Cr-Commit-Position: refs/heads/master@{#845122}
parent fa5fb125
......@@ -3525,8 +3525,14 @@ void RTCPeerConnection::CloseInternal() {
if (sctp_transport_) {
sctp_transport_->Close();
}
for (auto& dtls_transport_iter : dtls_transports_by_native_transport_) {
dtls_transport_iter.value->Close();
// Since Close() can trigger JS-level callbacks, iterate over a copy
// of the transports list.
auto dtls_transports_copy = dtls_transports_by_native_transport_;
for (auto& dtls_transport_iter : dtls_transports_copy) {
// Since "value" is a WeakPtr, check if it's still valid.
if (dtls_transport_iter.value) {
dtls_transport_iter.value->Close();
}
}
feature_handle_for_scheduler_.reset();
......
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