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

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: Sync with head 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
Index: webrtc/p2p/base/port.cc
diff --git a/webrtc/p2p/base/port.cc b/webrtc/p2p/base/port.cc
index b08cc4c91039f8149fac115a17e70f70236698ff..a33caac12bc9afcc802aaf4c3391f19be13ead06 100644
--- a/webrtc/p2p/base/port.cc
+++ b/webrtc/p2p/base/port.cc
@@ -271,7 +271,17 @@ void Port::AddAddress(const rtc::SocketAddress& address,
}
void Port::AddConnection(Connection* conn) {
pthatcher1 2016/05/27 18:42:54 If we're going to destroy existing connections whe
honghaiz3 2016/05/31 18:57:31 Done.
- connections_[conn->remote_candidate().address()] = 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->Destroy();
+ ret.first->second = conn;
pthatcher1 2016/05/27 18:42:54 Instead of putting logic in OnConnectionDestroyed
honghaiz3 2016/05/31 18:57:31 That would also do. But in the OnConnectionDestro
pthatcher1 2016/05/31 20:09:29 I think the check is overkill. We don't have the
honghaiz3 2016/06/01 16:37:59 Done. You are right. We only hit the replace-conne
+ }
conn->SignalDestroyed.connect(this, &Port::OnConnectionDestroyed);
SignalConnectionCreated(this, conn);
}
@@ -687,7 +697,12 @@ void Port::OnConnectionDestroyed(Connection* conn) {
AddressMap::iterator iter =
connections_.find(conn->remote_candidate().address());
ASSERT(iter != connections_.end());
+ if (iter->second != conn) {
+ // If the deleted connection is different than what we have now, ignore it.
+ return;
+ }
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

Powered by Google App Engine
This is Rietveld 408576698