Fix assertion failure when closing data channel, and add a unit test.
BUG=4066 R=jiayl@webrtc.org, juberti@webrtc.org Review URL: https://webrtc-codereview.appspot.com/31109004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7816 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
4b407aa985
commit
9b5467e88d
@ -441,7 +441,7 @@ void DataChannel::DisconnectFromTransport() {
|
|||||||
provider_->DisconnectDataChannel(this);
|
provider_->DisconnectDataChannel(this);
|
||||||
connected_to_provider_ = false;
|
connected_to_provider_ = false;
|
||||||
|
|
||||||
if (data_channel_type_ == cricket::DCT_SCTP) {
|
if (data_channel_type_ == cricket::DCT_SCTP && config_.id >= 0) {
|
||||||
provider_->RemoveSctpDataStream(config_.id);
|
provider_->RemoveSctpDataStream(config_.id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,9 +54,9 @@ class DataChannelProviderInterface {
|
|||||||
// Disconnects from the transport signals.
|
// Disconnects from the transport signals.
|
||||||
virtual void DisconnectDataChannel(DataChannel* data_channel) = 0;
|
virtual void DisconnectDataChannel(DataChannel* data_channel) = 0;
|
||||||
// Adds the data channel SID to the transport for SCTP.
|
// Adds the data channel SID to the transport for SCTP.
|
||||||
virtual void AddSctpDataStream(uint32 sid) = 0;
|
virtual void AddSctpDataStream(int sid) = 0;
|
||||||
// Removes the data channel SID from the transport for SCTP.
|
// Removes the data channel SID from the transport for SCTP.
|
||||||
virtual void RemoveSctpDataStream(uint32 sid) = 0;
|
virtual void RemoveSctpDataStream(int sid) = 0;
|
||||||
// Returns true if the transport channel is ready to send data.
|
// Returns true if the transport channel is ready to send data.
|
||||||
virtual bool ReadyToSendData() const = 0;
|
virtual bool ReadyToSendData() const = 0;
|
||||||
|
|
||||||
|
@ -423,3 +423,10 @@ TEST_F(SctpDataChannelTest, SendEmptyData) {
|
|||||||
EXPECT_EQ(webrtc::DataChannelInterface::kOpen,
|
EXPECT_EQ(webrtc::DataChannelInterface::kOpen,
|
||||||
webrtc_data_channel_->state());
|
webrtc_data_channel_->state());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Tests that a channel can be closed without being opened or assigned an sid.
|
||||||
|
TEST_F(SctpDataChannelTest, NeverOpened) {
|
||||||
|
provider_.set_transport_available(true);
|
||||||
|
webrtc_data_channel_->OnTransportChannelCreated();
|
||||||
|
webrtc_data_channel_->Close();
|
||||||
|
}
|
||||||
|
@ -71,7 +71,8 @@ class FakeDataChannelProvider : public webrtc::DataChannelProviderInterface {
|
|||||||
connected_channels_.erase(data_channel);
|
connected_channels_.erase(data_channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void AddSctpDataStream(uint32 sid) OVERRIDE {
|
virtual void AddSctpDataStream(int sid) OVERRIDE {
|
||||||
|
ASSERT(sid >= 0);
|
||||||
if (!transport_available_) {
|
if (!transport_available_) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -79,7 +80,8 @@ class FakeDataChannelProvider : public webrtc::DataChannelProviderInterface {
|
|||||||
recv_ssrcs_.insert(sid);
|
recv_ssrcs_.insert(sid);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void RemoveSctpDataStream(uint32 sid) OVERRIDE {
|
virtual void RemoveSctpDataStream(int sid) OVERRIDE {
|
||||||
|
ASSERT(sid >= 0);
|
||||||
send_ssrcs_.erase(sid);
|
send_ssrcs_.erase(sid);
|
||||||
recv_ssrcs_.erase(sid);
|
recv_ssrcs_.erase(sid);
|
||||||
}
|
}
|
||||||
|
@ -1136,7 +1136,7 @@ void WebRtcSession::DisconnectDataChannel(DataChannel* webrtc_data_channel) {
|
|||||||
data_channel_->SignalDataReceived.disconnect(webrtc_data_channel);
|
data_channel_->SignalDataReceived.disconnect(webrtc_data_channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebRtcSession::AddSctpDataStream(uint32 sid) {
|
void WebRtcSession::AddSctpDataStream(int sid) {
|
||||||
if (!data_channel_.get()) {
|
if (!data_channel_.get()) {
|
||||||
LOG(LS_ERROR) << "AddDataChannelStreams called when data_channel_ is NULL.";
|
LOG(LS_ERROR) << "AddDataChannelStreams called when data_channel_ is NULL.";
|
||||||
return;
|
return;
|
||||||
@ -1145,8 +1145,8 @@ void WebRtcSession::AddSctpDataStream(uint32 sid) {
|
|||||||
data_channel_->AddSendStream(cricket::StreamParams::CreateLegacy(sid));
|
data_channel_->AddSendStream(cricket::StreamParams::CreateLegacy(sid));
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebRtcSession::RemoveSctpDataStream(uint32 sid) {
|
void WebRtcSession::RemoveSctpDataStream(int sid) {
|
||||||
mediastream_signaling_->RemoveSctpDataChannel(static_cast<int>(sid));
|
mediastream_signaling_->RemoveSctpDataChannel(sid);
|
||||||
|
|
||||||
if (!data_channel_.get()) {
|
if (!data_channel_.get()) {
|
||||||
LOG(LS_ERROR) << "RemoveDataChannelStreams called when data_channel_ is "
|
LOG(LS_ERROR) << "RemoveDataChannelStreams called when data_channel_ is "
|
||||||
|
@ -203,8 +203,8 @@ class WebRtcSession : public cricket::BaseSession,
|
|||||||
cricket::SendDataResult* result) OVERRIDE;
|
cricket::SendDataResult* result) OVERRIDE;
|
||||||
virtual bool ConnectDataChannel(DataChannel* webrtc_data_channel) OVERRIDE;
|
virtual bool ConnectDataChannel(DataChannel* webrtc_data_channel) OVERRIDE;
|
||||||
virtual void DisconnectDataChannel(DataChannel* webrtc_data_channel) OVERRIDE;
|
virtual void DisconnectDataChannel(DataChannel* webrtc_data_channel) OVERRIDE;
|
||||||
virtual void AddSctpDataStream(uint32 sid) OVERRIDE;
|
virtual void AddSctpDataStream(int sid) OVERRIDE;
|
||||||
virtual void RemoveSctpDataStream(uint32 sid) OVERRIDE;
|
virtual void RemoveSctpDataStream(int sid) OVERRIDE;
|
||||||
virtual bool ReadyToSendData() const OVERRIDE;
|
virtual bool ReadyToSendData() const OVERRIDE;
|
||||||
|
|
||||||
// Implements DataChannelFactory.
|
// Implements DataChannelFactory.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user