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

Side by Side Diff: webrtc/p2p/base/turnport.cc

Issue 1415313004: Destroy a Connection if a CreatePermission request fails. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 2 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
OLDNEW
1 /* 1 /*
2 * Copyright 2012 The WebRTC Project Authors. All rights reserved. 2 * Copyright 2012 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 427 matching lines...) Expand 10 before | Expand all | Expand 10 after
438 } 438 }
439 439
440 // Create an entry, if needed, so we can get our permissions set up correctly. 440 // Create an entry, if needed, so we can get our permissions set up correctly.
441 CreateEntry(address.address()); 441 CreateEntry(address.address());
442 442
443 // A TURN port will have two candiates, STUN and TURN. STUN may not 443 // A TURN port will have two candiates, STUN and TURN. STUN may not
444 // present in all cases. If present stun candidate will be added first 444 // present in all cases. If present stun candidate will be added first
445 // and TURN candidate later. 445 // and TURN candidate later.
446 for (size_t index = 0; index < Candidates().size(); ++index) { 446 for (size_t index = 0; index < Candidates().size(); ++index) {
447 if (Candidates()[index].type() == RELAY_PORT_TYPE) { 447 if (Candidates()[index].type() == RELAY_PORT_TYPE) {
448 ProxyConnection* conn = new ProxyConnection(this, index, address); 448 TurnConnection* conn = new TurnConnection(this, index, address);
449 conn->SignalDestroyed.connect(this, &TurnPort::OnConnectionDestroyed); 449 conn->SignalDestroyed.connect(this, &TurnPort::OnConnectionDestroyed);
450 AddConnection(conn); 450 AddConnection(conn);
451 return conn; 451 return conn;
452 } 452 }
453 } 453 }
454 return NULL; 454 return NULL;
455 } 455 }
456 456
457 int TurnPort::SetOption(rtc::Socket::Option opt, int value) { 457 int TurnPort::SetOption(rtc::Socket::Option opt, int value) {
458 if (!socket_) { 458 if (!socket_) {
(...skipping 902 matching lines...) Expand 10 before | Expand all | Expand 10 after
1361 // TODO(mallinath) - Implement handling of error response for channel 1361 // TODO(mallinath) - Implement handling of error response for channel
1362 // bind request as per http://tools.ietf.org/html/rfc5766#section-11.3 1362 // bind request as per http://tools.ietf.org/html/rfc5766#section-11.3
1363 if (code == STUN_ERROR_STALE_NONCE) { 1363 if (code == STUN_ERROR_STALE_NONCE) {
1364 if (port_->UpdateNonce(response)) { 1364 if (port_->UpdateNonce(response)) {
1365 // Send channel bind request with fresh nonce. 1365 // Send channel bind request with fresh nonce.
1366 SendChannelBindRequest(0); 1366 SendChannelBindRequest(0);
1367 } 1367 }
1368 } 1368 }
1369 } 1369 }
1370 1370
1371 TurnConnection::TurnConnection(TurnPort* port,
1372 size_t index,
1373 const Candidate& remote_candidate)
1374 : ProxyConnection(port, index, remote_candidate), turn_port_(port) {
1375 turn_port_->SignalCreatePermissionResult.connect(
1376 this, &TurnConnection::OnCreatePermissionResult);
1377 }
1378
1379 TurnConnection::~TurnConnection() {
1380 turn_port_->SignalCreatePermissionResult.disconnect(this);
1381 }
1382
1383 void TurnConnection::OnCreatePermissionResult(
1384 TurnPort* port,
1385 const rtc::SocketAddress& remote_address,
1386 int code) {
1387 RTC_DCHECK(port == turn_port_);
1388 if (remote_address != remote_candidate_.address() || code == 0) {
1389 return;
1390 }
1391 LOG_J(LS_ERROR, this) << "Received TURN CreatePermission error response, "
1392 << "code=" << code << "; killing connection.";
1393 set_state(STATE_FAILED);
1394 Destroy();
1395 }
1396
1371 } // namespace cricket 1397 } // namespace cricket
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698