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 <hta@webrtc.org>
Reviewed-by: Taylor <deadbeef@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31293}
This commit is contained in:
Harald Alvestrand 2020-05-12 12:59:02 +02:00 committed by Commit Bot
parent cf84607875
commit 37e42bed01
2 changed files with 6 additions and 6 deletions

View File

@ -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.

View File

@ -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());
}