Commit 8668e3f0 authored by sergeyu's avatar sergeyu Committed by Commit bot

Fix side-effect in DCHECK that breaks another DCHECK in JingleSession.

DCHECK(!channels_[name]) adds NULL channel with |name| into the
map, which was breaking DCHECK in JingleSession destructor. Replaced
with another DCHECK that doesn't have side-effects. Added unittest
to catch this problem.
Also removed no-op line from ~JingleSession().

Review URL: https://codereview.chromium.org/594743002

Cr-Commit-Position: refs/heads/master@{#296224}
parent 7fc5f5fe
...@@ -85,7 +85,6 @@ JingleSession::~JingleSession() { ...@@ -85,7 +85,6 @@ JingleSession::~JingleSession() {
STLDeleteContainerPointers(transport_info_requests_.begin(), STLDeleteContainerPointers(transport_info_requests_.begin(),
transport_info_requests_.end()); transport_info_requests_.end());
channel_multiplexer_.reset();
DCHECK(channels_.empty()); DCHECK(channels_.empty());
session_manager_->SessionDestroyed(this); session_manager_->SessionDestroyed(this);
...@@ -274,7 +273,7 @@ void JingleSession::CancelChannelCreation(const std::string& name) { ...@@ -274,7 +273,7 @@ void JingleSession::CancelChannelCreation(const std::string& name) {
if (it != channels_.end()) { if (it != channels_.end()) {
DCHECK(!it->second->is_connected()); DCHECK(!it->second->is_connected());
delete it->second; delete it->second;
DCHECK(!channels_[name]); DCHECK(channels_.find(name) == channels_.end());
} }
} }
......
...@@ -521,5 +521,19 @@ TEST_F(JingleSessionTest, TestFailedChannelAuth) { ...@@ -521,5 +521,19 @@ TEST_F(JingleSessionTest, TestFailedChannelAuth) {
EXPECT_TRUE(!host_socket_.get()); EXPECT_TRUE(!host_socket_.get());
} }
TEST_F(JingleSessionTest, TestCancelChannelCreation) {
CreateSessionManagers(1, FakeAuthenticator::REJECT_CHANNEL);
ASSERT_NO_FATAL_FAILURE(
InitiateConnection(1, FakeAuthenticator::ACCEPT, false));
client_session_->GetTransportChannelFactory()->CreateChannel(
kChannelName, base::Bind(&JingleSessionTest::OnClientChannelCreated,
base::Unretained(this)));
client_session_->GetTransportChannelFactory()->CancelChannelCreation(
kChannelName);
EXPECT_TRUE(!client_socket_.get());
}
} // namespace protocol } // namespace protocol
} // namespace remoting } // namespace remoting
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment