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

Side by Side 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, 6 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2004 The WebRTC Project Authors. All rights reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 c.set_network_type(network_->type()); 263 c.set_network_type(network_->type());
264 c.set_related_address(related_address); 264 c.set_related_address(related_address);
265 candidates_.push_back(c); 265 candidates_.push_back(c);
266 SignalCandidateReady(this, c); 266 SignalCandidateReady(this, c);
267 267
268 if (final) { 268 if (final) {
269 SignalPortComplete(this); 269 SignalPortComplete(this);
270 } 270 }
271 } 271 }
272 272
273 void Port::AddConnection(Connection* conn) { 273 void Port::AddOrReplaceConnection(Connection* conn) {
274 connections_[conn->remote_candidate().address()] = conn; 274 auto ret = connections_.insert(
275 std::make_pair(conn->remote_candidate().address(), conn));
276 // If there is a different connection on the same remote address, replace
277 // it with the new one and destroy the old one.
278 if (ret.second == false && ret.first->second != conn) {
279 LOG_J(LS_WARNING, this)
280 << "A new connection was created on an existing remote address. "
281 << "New remote candidate: " << conn->remote_candidate().ToString();
282 ret.first->second->SignalDestroyed.disconnect(this);
283 ret.first->second->Destroy();
284 ret.first->second = conn;
285 }
275 conn->SignalDestroyed.connect(this, &Port::OnConnectionDestroyed); 286 conn->SignalDestroyed.connect(this, &Port::OnConnectionDestroyed);
276 SignalConnectionCreated(this, conn); 287 SignalConnectionCreated(this, conn);
277 } 288 }
278 289
279 void Port::OnReadPacket( 290 void Port::OnReadPacket(
280 const char* data, size_t size, const rtc::SocketAddress& addr, 291 const char* data, size_t size, const rtc::SocketAddress& addr,
281 ProtocolType proto) { 292 ProtocolType proto) {
282 // If the user has enabled port packets, just hand this over. 293 // If the user has enabled port packets, just hand this over.
283 if (enable_port_packets_) { 294 if (enable_port_packets_) {
284 SignalReadPacket(this, data, size, addr); 295 SignalReadPacket(this, data, size, addr);
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 692
682 void Port::EnablePortPackets() { 693 void Port::EnablePortPackets() {
683 enable_port_packets_ = true; 694 enable_port_packets_ = true;
684 } 695 }
685 696
686 void Port::OnConnectionDestroyed(Connection* conn) { 697 void Port::OnConnectionDestroyed(Connection* conn) {
687 AddressMap::iterator iter = 698 AddressMap::iterator iter =
688 connections_.find(conn->remote_candidate().address()); 699 connections_.find(conn->remote_candidate().address());
689 ASSERT(iter != connections_.end()); 700 ASSERT(iter != connections_.end());
690 connections_.erase(iter); 701 connections_.erase(iter);
702 HandleConnectionDestroyed(conn);
691 703
692 // On the controlled side, ports time out after all connections fail. 704 // On the controlled side, ports time out after all connections fail.
693 // Note: If a new connection is added after this message is posted, but it 705 // Note: If a new connection is added after this message is posted, but it
694 // fails and is removed before kPortTimeoutDelay, then this message will 706 // fails and is removed before kPortTimeoutDelay, then this message will
695 // still cause the Port to be destroyed. 707 // still cause the Port to be destroyed.
696 if (dead()) { 708 if (dead()) {
697 thread_->PostDelayed(timeout_delay_, this, MSG_DEAD); 709 thread_->PostDelayed(timeout_delay_, this, MSG_DEAD);
698 } 710 }
699 } 711 }
700 712
(...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after
1505 ASSERT(sent < 0); 1517 ASSERT(sent < 0);
1506 error_ = port_->GetError(); 1518 error_ = port_->GetError();
1507 sent_packets_discarded_++; 1519 sent_packets_discarded_++;
1508 } else { 1520 } else {
1509 send_rate_tracker_.AddSamples(sent); 1521 send_rate_tracker_.AddSamples(sent);
1510 } 1522 }
1511 return sent; 1523 return sent;
1512 } 1524 }
1513 1525
1514 } // namespace cricket 1526 } // namespace cricket
OLDNEW
« 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