Remove an invoke for datahannel transport uninitialization during Close.

Bug: none
Change-Id: Ic0d482a8a045d3aa0fcaf13e43f8a156fa3560d6
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/324301
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Tomas Gunnarsson <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#40982}
This commit is contained in:
Tommi 2023-10-21 16:50:09 +02:00 committed by WebRTC LUCI CQ
parent 840cf78600
commit 2919075ce3
3 changed files with 16 additions and 14 deletions

View File

@ -566,10 +566,8 @@ PeerConnection::~PeerConnection() {
if (sdp_handler_) {
// Don't destroy BaseChannels until after stats has been cleaned up so that
// the last stats request can still read from the channels.
sdp_handler_->DestroyAllChannels();
sdp_handler_->DestroyMediaChannels();
RTC_LOG(LS_INFO) << "Session: " << session_id() << " is destroyed.";
sdp_handler_->ResetSessionDescFactory();
}
@ -584,6 +582,8 @@ PeerConnection::~PeerConnection() {
if (network_thread_safety_)
network_thread_safety_->SetNotAlive();
});
sctp_mid_s_.reset();
SetSctpTransportName("");
// call_ and event_log_ must be destroyed on the worker thread.
worker_thread()->BlockingCall([this] {
@ -1899,7 +1899,12 @@ void PeerConnection::Close() {
// Don't destroy BaseChannels until after stats has been cleaned up so that
// the last stats request can still read from the channels.
sdp_handler_->DestroyAllChannels();
// TODO(tommi): The voice/video channels will be partially uninitialized on
// the network thread (see `RtpTransceiver::ClearChannel`), partially on the
// worker thread (see `PushNewMediaChannelAndDeleteChannel`) and then
// eventually freed on the signaling thread.
// It would be good to combine those steps with the teardown steps here.
sdp_handler_->DestroyMediaChannels();
// The event log is used in the transport controller, which must be outlived
// by the former. CreateOffer by the peer connection is implemented
@ -1912,12 +1917,8 @@ void PeerConnection::Close() {
}
network_thread()->BlockingCall([this] {
// Data channels will already have been unset via the DestroyAllChannels()
// call above, which triggers a call to TeardownDataChannelTransport_n().
// TODO(tommi): ^^ That's not exactly optimal since this is yet another
// blocking hop to the network thread during Close(). Further still, the
// voice/video/data channels will be cleared on the worker thread.
RTC_DCHECK_RUN_ON(network_thread());
TeardownDataChannelTransport_n({});
transport_controller_.reset();
port_allocator_->DiscardCandidatePool();
if (network_thread_safety_) {
@ -1925,6 +1926,9 @@ void PeerConnection::Close() {
}
});
sctp_mid_s_.reset();
SetSctpTransportName("");
worker_thread()->BlockingCall([this] {
RTC_DCHECK_RUN_ON(worker_thread());
worker_thread_safety_->SetNotAlive();

View File

@ -5204,7 +5204,7 @@ RTCError SdpOfferAnswerHandler::CreateChannels(const SessionDescription& desc) {
return RTCError::OK();
}
void SdpOfferAnswerHandler::DestroyAllChannels() {
void SdpOfferAnswerHandler::DestroyMediaChannels() {
RTC_DCHECK_RUN_ON(signaling_thread());
if (!transceivers()) {
return;
@ -5227,8 +5227,6 @@ void SdpOfferAnswerHandler::DestroyAllChannels() {
transceiver->internal()->ClearChannel();
}
}
pc_->DestroyDataChannelTransport({});
}
void SdpOfferAnswerHandler::GenerateMediaDescriptionOptions(

View File

@ -166,8 +166,8 @@ class SdpOfferAnswerHandler : public SdpStateProvider {
// See also `InternalDataChannelInit::fallback_ssl_role`.
absl::optional<rtc::SSLRole> GuessSslRole() const;
// Destroys all BaseChannels and destroys the SCTP data channel, if present.
void DestroyAllChannels();
// Destroys all media BaseChannels.
void DestroyMediaChannels();
rtc::scoped_refptr<StreamCollectionInterface> local_streams();
rtc::scoped_refptr<StreamCollectionInterface> remote_streams();