Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(855)

Unified Diff: webrtc/p2p/base/p2ptransportchannel_unittest.cc

Issue 2171183002: Remove ports that are not used by any channel after timeout (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: . Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/p2p/base/p2ptransportchannel.cc ('k') | webrtc/p2p/base/port.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/p2p/base/p2ptransportchannel_unittest.cc
diff --git a/webrtc/p2p/base/p2ptransportchannel_unittest.cc b/webrtc/p2p/base/p2ptransportchannel_unittest.cc
index c9600ddddd4a0b719f3f67a6086d1ce8b1d66b3d..b10562105966078f5c464a1e8d3656529b59c211 100644
--- a/webrtc/p2p/base/p2ptransportchannel_unittest.cc
+++ b/webrtc/p2p/base/p2ptransportchannel_unittest.cc
@@ -2497,6 +2497,13 @@ class P2PTransportChannelPingTest : public testing::Test,
return static_cast<Port*>(ch->ports()[0]);
}
+ Port* GetPrunedPort(P2PTransportChannel* ch) {
+ if (ch->pruned_ports().empty()) {
+ return nullptr;
+ }
+ return static_cast<Port*>(ch->pruned_ports()[0]);
+ }
+
Connection* GetConnectionTo(P2PTransportChannel* ch,
const std::string& ip,
int port_num) {
@@ -3579,14 +3586,14 @@ TEST_F(P2PTransportChannelPingTest, TestIceRoleUpdatedOnPortAfterIceRestart) {
}
// Test that after some amount of time without receiving data, the connection
-// and port are destroyed.
-TEST_F(P2PTransportChannelPingTest, TestPortDestroyedAfterTimeout) {
+// will be destroyed. The port will only be destroyed after it is marked as
+// "pruned."
+TEST_F(P2PTransportChannelPingTest, TestPortDestroyedAfterTimeoutAndPruned) {
rtc::ScopedFakeClock fake_clock;
FakePortAllocator pa(rtc::Thread::Current(), nullptr);
P2PTransportChannel ch("test channel", ICE_CANDIDATE_COMPONENT_DEFAULT, &pa);
PrepareChannel(&ch);
- // Only a controlled channel should expect its ports to be destroyed.
ch.SetIceRole(ICEROLE_CONTROLLED);
ch.MaybeStartGathering();
ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "1.1.1.1", 1, 1));
@@ -3600,7 +3607,14 @@ TEST_F(P2PTransportChannelPingTest, TestPortDestroyedAfterTimeout) {
fake_clock.AdvanceTime(rtc::TimeDelta::FromSeconds(1));
}
EXPECT_EQ(nullptr, GetConnectionTo(&ch, "1.1.1.1", 1));
- EXPECT_EQ(nullptr, GetPort(&ch));
+ // Port will not be removed because it is not pruned yet.
+ PortInterface* port = GetPort(&ch);
+ ASSERT_NE(nullptr, port);
+
+ // If the session prunes all ports, the port will be destroyed.
+ ch.allocator_session()->PruneAllPorts();
+ EXPECT_EQ_SIMULATED_WAIT(nullptr, GetPort(&ch), 1, fake_clock);
+ EXPECT_EQ_SIMULATED_WAIT(nullptr, GetPrunedPort(&ch), 1, fake_clock);
}
class P2PTransportChannelMostLikelyToWorkFirstTest
« no previous file with comments | « webrtc/p2p/base/p2ptransportchannel.cc ('k') | webrtc/p2p/base/port.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698