Don't crash when a datachannel can't get an ID
This is exercised by WPT test RTCDataChannel-id. Bug: chromium:945256 Change-Id: I53781dc874134f8c68a49c201848377b93b8858f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/128871 Reviewed-by: Henrik Boström <hbos@webrtc.org> Reviewed-by: Seth Hampson <shampson@webrtc.org> Commit-Queue: Harald Alvestrand <hta@webrtc.org> Cr-Commit-Position: refs/heads/master@{#27300}
This commit is contained in:

committed by
Commit Bot

parent
2547d2cf2b
commit
77c442ca19
@ -414,7 +414,10 @@ void DataChannel::OnChannelReady(bool writable) {
|
||||
if (!writable) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If the datachannel has not been assigned an ID, ignore update.
|
||||
if (id() < 0) {
|
||||
return;
|
||||
}
|
||||
SendQueuedControlMessages();
|
||||
SendQueuedDataMessages();
|
||||
UpdateState();
|
||||
|
@ -613,6 +613,19 @@ TEST_F(SctpDataChannelTest, TransportDestroyedWhileDataBuffered) {
|
||||
webrtc_data_channel_->state(), kDefaultTimeout);
|
||||
}
|
||||
|
||||
// Verifies that if the allocator is exhausted before connecting, the
|
||||
// datachannel does not cause a crash, but remains unconnected.
|
||||
TEST_F(SctpDataChannelTest, NoCrashAfterTransportBecomesAvailable) {
|
||||
// This is the same as SetChannelReady, but without setting the id.
|
||||
provider_->set_transport_available(true);
|
||||
webrtc_data_channel_->OnTransportChannelCreated();
|
||||
provider_->set_ready_to_send(true);
|
||||
// The datachannel's ID is not set, and it remains in "connecting" state.
|
||||
EXPECT_EQ(-1, webrtc_data_channel_->id());
|
||||
EXPECT_EQ(webrtc::DataChannelInterface::kConnecting,
|
||||
webrtc_data_channel_->state());
|
||||
}
|
||||
|
||||
class SctpSidAllocatorTest : public testing::Test {
|
||||
protected:
|
||||
SctpSidAllocator allocator_;
|
||||
|
Reference in New Issue
Block a user