Revert "Add thread checker to PortAllocator and its subclasses and fix a bug"

This reverts commit fc43d11717e16dd427ac84fee614e5511e43cefd.

Reason for revert: Crashes downstream tests

Original change's description:
> Add thread checker to PortAllocator and its subclasses and fix a bug
> causing memory contention by threads.
> 
> PortAllocator and its subclasses assume all of their methods except the
> constructor must be called on the same thread (the network thread in
> practice). This CL adds a thread checker to PortAllocator and its
> subclasses for thread safety, and fixes bugs of invoking some of their
> methods in PeerConnection on the signaling thread.
> 
> Bug: webrtc:9112
> Change-Id: I33ba9bae72ec09a45ec70435962f3f25cd31583c
> Reviewed-on: https://webrtc-review.googlesource.com/66945
> Commit-Queue: Qingsi Wang <qingsi@google.com>
> Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#22814}

TBR=deadbeef@webrtc.org,pthatcher@google.com,pthatcher@webrtc.org,qingsi@google.com,honghaiz@webrtc.org

Change-Id: I2db6561d5d6366d38caa58c3e719d0d48eda70c2
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:9112
Reviewed-on: https://webrtc-review.googlesource.com/69200
Reviewed-by: Patrik Höglund <phoglund@webrtc.org>
Commit-Queue: Patrik Höglund <phoglund@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22818}
This commit is contained in:
Patrik Höglund
2018-04-11 11:13:57 +00:00
committed by Commit Bot
parent 9df3cf3e8c
commit 3dc41069ef
11 changed files with 98 additions and 215 deletions

View File

@ -1414,6 +1414,31 @@ TEST_P(PeerConnectionInterfaceTest,
EXPECT_TRUE(raw_port_allocator->prune_turn_ports());
}
// Test that the PeerConnection initializes the port allocator passed into it,
// and on the correct thread.
TEST_P(PeerConnectionInterfaceTest,
CreatePeerConnectionInitializesPortAllocatorOnNetworkThread) {
std::unique_ptr<rtc::Thread> network_thread(
rtc::Thread::CreateWithSocketServer());
network_thread->Start();
rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> pc_factory(
webrtc::CreatePeerConnectionFactory(
network_thread.get(), rtc::Thread::Current(), rtc::Thread::Current(),
fake_audio_capture_module_,
webrtc::CreateBuiltinAudioEncoderFactory(),
webrtc::CreateBuiltinAudioDecoderFactory(), nullptr, nullptr));
std::unique_ptr<cricket::FakePortAllocator> port_allocator(
new cricket::FakePortAllocator(network_thread.get(), nullptr));
cricket::FakePortAllocator* raw_port_allocator = port_allocator.get();
PeerConnectionInterface::RTCConfiguration config;
rtc::scoped_refptr<PeerConnectionInterface> pc(
pc_factory->CreatePeerConnection(
config, nullptr, std::move(port_allocator), nullptr, &observer_));
// FakePortAllocator RTC_CHECKs that it's initialized on the right thread,
// so all we have to do here is check that it's initialized.
EXPECT_TRUE(raw_port_allocator->initialized());
}
// Check that GetConfiguration returns the configuration the PeerConnection was
// constructed with, before SetConfiguration is called.
TEST_P(PeerConnectionInterfaceTest, GetConfigurationAfterCreatePeerConnection) {