Drop the DataChannel message if it's received when the channel is not open.
It may happen when the JS has closed the channel on the signaling thread while messages are received on the worker thread and posted before the state change is pushed to the worker thread. BUG=crbug/363005 R=mallinath@webrtc.org Review URL: https://webrtc-codereview.appspot.com/19469005 git-svn-id: http://webrtc.googlecode.com/svn/trunk@6161 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@ -284,6 +284,10 @@ void DataChannel::OnDataEngineClose() {
|
|||||||
void DataChannel::OnDataReceived(cricket::DataChannel* channel,
|
void DataChannel::OnDataReceived(cricket::DataChannel* channel,
|
||||||
const cricket::ReceiveDataParams& params,
|
const cricket::ReceiveDataParams& params,
|
||||||
const talk_base::Buffer& payload) {
|
const talk_base::Buffer& payload) {
|
||||||
|
if (state_ != kOpen) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
uint32 expected_ssrc =
|
uint32 expected_ssrc =
|
||||||
(data_channel_type_ == cricket::DCT_RTP) ? receive_ssrc_ : config_.id;
|
(data_channel_type_ == cricket::DCT_RTP) ? receive_ssrc_ : config_.id;
|
||||||
if (params.ssrc != expected_ssrc) {
|
if (params.ssrc != expected_ssrc) {
|
||||||
|
@ -302,3 +302,16 @@ TEST_F(SctpDataChannelTest, OpenAckRoleInitialization) {
|
|||||||
webrtc::InternalDataChannelInit init2(base);
|
webrtc::InternalDataChannelInit init2(base);
|
||||||
EXPECT_EQ(webrtc::InternalDataChannelInit::kNone, init2.open_handshake_role);
|
EXPECT_EQ(webrtc::InternalDataChannelInit::kNone, init2.open_handshake_role);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Tests that message is dropped if the channel is not open.
|
||||||
|
TEST_F(SctpDataChannelTest, ReceivedDataDroppedIfNotOpen) {
|
||||||
|
AddObserver();
|
||||||
|
EXPECT_CALL(*(observer_.get()), OnMessage(testing::_)).Times(0);
|
||||||
|
|
||||||
|
webrtc_data_channel_->SetSctpSid(1);
|
||||||
|
|
||||||
|
cricket::ReceiveDataParams params;
|
||||||
|
params.ssrc = 1;
|
||||||
|
webrtc::DataBuffer buffer("abcd");
|
||||||
|
webrtc_data_channel_->OnDataReceived(NULL, params, buffer.data);
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user