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

Unified Diff: webrtc/p2p/base/p2ptransportchannel.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.h ('k') | webrtc/p2p/base/p2ptransportchannel_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/p2p/base/p2ptransportchannel.cc
diff --git a/webrtc/p2p/base/p2ptransportchannel.cc b/webrtc/p2p/base/p2ptransportchannel.cc
index c12e8dbf66abe539bf8547d579aad4927b2809df..32a996c5d5758690390d90d8e495efaf4789deef 100644
--- a/webrtc/p2p/base/p2ptransportchannel.cc
+++ b/webrtc/p2p/base/p2ptransportchannel.cc
@@ -143,14 +143,15 @@ void P2PTransportChannel::AddAllocatorSession(
this, &P2PTransportChannel::OnCandidatesRemoved);
session->SignalCandidatesAllocationDone.connect(
this, &P2PTransportChannel::OnCandidatesAllocationDone);
+ if (!allocator_sessions_.empty()) {
+ allocator_session()->PruneAllPorts();
+ }
+ allocator_sessions_.push_back(std::move(session));
// We now only want to apply new candidates that we receive to the ports
// created by this new session because these are replacing those of the
// previous sessions.
- pruned_ports_.insert(pruned_ports_.end(), ports_.begin(), ports_.end());
- ports_.clear();
-
- allocator_sessions_.push_back(std::move(session));
+ PruneAllPorts();
}
void P2PTransportChannel::AddConnection(Connection* connection) {
@@ -238,7 +239,7 @@ void P2PTransportChannel::SetIceRole(IceRole ice_role) {
for (PortInterface* port : ports_) {
port->SetIceRole(ice_role);
}
- // Update role on removed ports as well, because they may still have
+ // Update role on pruned ports as well, because they may still have
// connections alive that should be using the correct role.
for (PortInterface* port : pruned_ports_) {
port->SetIceRole(ice_role);
@@ -1688,7 +1689,7 @@ void P2PTransportChannel::OnPortsPruned(
const std::vector<PortInterface*>& ports) {
ASSERT(worker_thread_ == rtc::Thread::Current());
for (PortInterface* port : ports) {
- if (OnPortPruned(port)) {
+ if (PrunePort(port)) {
LOG(INFO) << "Removed port: " << port->ToString() << " " << ports_.size()
<< " remaining";
}
@@ -1727,7 +1728,12 @@ void P2PTransportChannel::OnRegatherOnFailedNetworks() {
MSG_REGATHER_ON_FAILED_NETWORKS);
}
-bool P2PTransportChannel::OnPortPruned(PortInterface* port) {
+void P2PTransportChannel::PruneAllPorts() {
+ pruned_ports_.insert(pruned_ports_.end(), ports_.begin(), ports_.end());
+ ports_.clear();
+}
+
+bool P2PTransportChannel::PrunePort(PortInterface* port) {
auto it = std::find(ports_.begin(), ports_.end(), port);
// Don't need to do anything if the port has been deleted from the port list.
if (it == ports_.end()) {
« no previous file with comments | « webrtc/p2p/base/p2ptransportchannel.h ('k') | webrtc/p2p/base/p2ptransportchannel_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698