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

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

Issue 2018693002: Create a new connection if a candidate reuses an address (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: address comments Created 4 years, 7 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/port.h ('k') | webrtc/p2p/base/port_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/p2p/base/port.cc
diff --git a/webrtc/p2p/base/port.cc b/webrtc/p2p/base/port.cc
index b08cc4c91039f8149fac115a17e70f70236698ff..0ce946582aed64e2e44b060331e0aab20a429c0d 100644
--- a/webrtc/p2p/base/port.cc
+++ b/webrtc/p2p/base/port.cc
@@ -270,8 +270,19 @@ void Port::AddAddress(const rtc::SocketAddress& address,
}
}
-void Port::AddConnection(Connection* conn) {
- connections_[conn->remote_candidate().address()] = conn;
+void Port::AddOrReplaceConnection(Connection* conn) {
+ auto ret = connections_.insert(
+ std::make_pair(conn->remote_candidate().address(), conn));
+ // If there is a different connection on the same remote address, replace
+ // it with the new one and destroy the old one.
+ if (ret.second == false && ret.first->second != conn) {
+ LOG_J(LS_WARNING, this)
+ << "A new connection was created on an existing remote address. "
+ << "New remote candidate: " << conn->remote_candidate().ToString();
+ ret.first->second->SignalDestroyed.disconnect(this);
+ ret.first->second->Destroy();
+ ret.first->second = conn;
+ }
conn->SignalDestroyed.connect(this, &Port::OnConnectionDestroyed);
SignalConnectionCreated(this, conn);
}
@@ -688,6 +699,7 @@ void Port::OnConnectionDestroyed(Connection* conn) {
connections_.find(conn->remote_candidate().address());
ASSERT(iter != connections_.end());
connections_.erase(iter);
+ HandleConnectionDestroyed(conn);
// On the controlled side, ports time out after all connections fail.
// Note: If a new connection is added after this message is posted, but it
« no previous file with comments | « webrtc/p2p/base/port.h ('k') | webrtc/p2p/base/port_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698