From 37e42bed01071581b091f3240abc8e6238d86677 Mon Sep 17 00:00:00 2001 From: Harald Alvestrand Date: Tue, 12 May 2020 12:59:02 +0200 Subject: [PATCH] Give correct error code when SCTP is abruptly terminated. Bug: chromium:1030631 Change-Id: I1890d6c7b30c06de1f4fdc6fe0cf1ff62ea4a63d Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174830 Commit-Queue: Harald Alvestrand Reviewed-by: Taylor Cr-Commit-Position: refs/heads/master@{#31293} --- pc/data_channel.cc | 8 ++++---- pc/data_channel_unittest.cc | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/pc/data_channel.cc b/pc/data_channel.cc index 4f871b4d50..0b9af37544 100644 --- a/pc/data_channel.cc +++ b/pc/data_channel.cc @@ -370,10 +370,10 @@ void DataChannel::OnTransportChannelClosed() { // The SctpTransport is unusable (for example, because the SCTP m= section // was rejected, or because the DTLS transport closed), so we need to close // abruptly. - // Note: this needs to differentiate between normal close and error close. - // https://w3c.github.io/webrtc-pc/#announcing-a-data-channel-as-closed - CloseAbruptlyWithError( - RTCError(RTCErrorType::NETWORK_ERROR, "Transport channel closed")); + RTCError error = RTCError(RTCErrorType::OPERATION_ERROR_WITH_DATA, + "Transport channel closed"); + error.set_error_detail(RTCErrorDetailType::SCTP_FAILURE); + CloseAbruptlyWithError(std::move(error)); } // The remote peer request that this channel shall be closed. diff --git a/pc/data_channel_unittest.cc b/pc/data_channel_unittest.cc index 6bb8f7e5c7..b29be338cb 100644 --- a/pc/data_channel_unittest.cc +++ b/pc/data_channel_unittest.cc @@ -630,9 +630,9 @@ TEST_F(SctpDataChannelTest, TransportDestroyedWhileDataBuffered) { EXPECT_EQ_WAIT(webrtc::DataChannelInterface::kClosed, webrtc_data_channel_->state(), kDefaultTimeout); EXPECT_FALSE(webrtc_data_channel_->error().ok()); - EXPECT_EQ(webrtc::RTCErrorType::NETWORK_ERROR, + EXPECT_EQ(webrtc::RTCErrorType::OPERATION_ERROR_WITH_DATA, webrtc_data_channel_->error().type()); - EXPECT_EQ(webrtc::RTCErrorDetailType::NONE, + EXPECT_EQ(webrtc::RTCErrorDetailType::SCTP_FAILURE, webrtc_data_channel_->error().error_detail()); }