diff --git a/talk/p2p/client/basicportallocator.cc b/talk/p2p/client/basicportallocator.cc index 762726fbb..549e6f489 100644 --- a/talk/p2p/client/basicportallocator.cc +++ b/talk/p2p/client/basicportallocator.cc @@ -398,8 +398,6 @@ void BasicPortAllocatorSession::OnAllocate() { DoAllocate(); allocation_started_ = true; - if (running_) - network_thread_->PostDelayed(ALLOCATE_DELAY, this, MSG_ALLOCATE); } // For each network, see if we have a sequence that covers it already. If not, diff --git a/talk/p2p/client/portallocator_unittest.cc b/talk/p2p/client/portallocator_unittest.cc index 44a8f2725..b9def3041 100644 --- a/talk/p2p/client/portallocator_unittest.cc +++ b/talk/p2p/client/portallocator_unittest.cc @@ -280,6 +280,19 @@ TEST_F(PortAllocatorTest, TestBasic) { EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); } +// Tests that we allocator session not trying to allocate ports for every 250ms. +TEST_F(PortAllocatorTest, TestNoNetworkInterface) { + EXPECT_TRUE(CreateSession(cricket::ICE_CANDIDATE_COMPONENT_RTP)); + session_->StartGettingPorts(); + // Waiting for one second to make sure BasicPortAllocatorSession has not + // called OnAllocate multiple times. In old behavior it's called every 250ms. + // When there are no network interfaces, each execution of OnAllocate will + // result in SignalCandidatesAllocationDone signal. + talk_base::Thread::Current()->ProcessMessages(1000); + EXPECT_TRUE(candidate_allocation_done_); + EXPECT_EQ(0U, candidates_.size()); +} + // Tests that we can get all the desired addresses successfully. TEST_F(PortAllocatorTest, TestGetAllPortsWithMinimumStepDelay) { AddInterface(kClientAddr);