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

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: Adding comment. 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
« no previous file with comments | « webrtc/p2p/base/turnport.h ('k') | webrtc/p2p/base/turnport_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 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 880 matching lines...) Expand 10 before | Expand all | Expand 10 after
1339 port_->SignalCreatePermissionResult(port_, ext_addr_, 0); 1339 port_->SignalCreatePermissionResult(port_, ext_addr_, 0);
1340 } 1340 }
1341 1341
1342 void TurnEntry::OnCreatePermissionError(StunMessage* response, int code) { 1342 void TurnEntry::OnCreatePermissionError(StunMessage* response, int code) {
1343 if (code == STUN_ERROR_STALE_NONCE) { 1343 if (code == STUN_ERROR_STALE_NONCE) {
1344 if (port_->UpdateNonce(response)) { 1344 if (port_->UpdateNonce(response)) {
1345 SendCreatePermissionRequest(); 1345 SendCreatePermissionRequest();
1346 } 1346 }
1347 } else { 1347 } else {
1348 // Send signal with error code. 1348 // Send signal with error code.
1349 port_->SignalCreatePermissionResult(port_, ext_addr_, code); 1349 port_->SignalCreatePermissionResult(port_, ext_addr_, code);
juberti 2015/10/26 21:27:24 Rather than using the signal, I think it would be
1350 } 1350 }
1351 } 1351 }
1352 1352
1353 void TurnEntry::OnChannelBindSuccess() { 1353 void TurnEntry::OnChannelBindSuccess() {
1354 LOG_J(LS_INFO, port_) << "Channel bind for " << ext_addr_.ToSensitiveString() 1354 LOG_J(LS_INFO, port_) << "Channel bind for " << ext_addr_.ToSensitiveString()
1355 << " succeeded"; 1355 << " succeeded";
1356 ASSERT(state_ == STATE_BINDING || state_ == STATE_BOUND); 1356 ASSERT(state_ == STATE_BINDING || state_ == STATE_BOUND);
1357 state_ = STATE_BOUND; 1357 state_ = STATE_BOUND;
1358 } 1358 }
1359 1359
1360 void TurnEntry::OnChannelBindError(StunMessage* response, int code) { 1360 void TurnEntry::OnChannelBindError(StunMessage* response, int code) {
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 this signal is for another connection, or it's a success, ignore it.
1389 if (remote_address != remote_candidate_.address() || code == 0) {
1390 return;
1391 }
1392 LOG_J(LS_ERROR, this) << "Received TURN CreatePermission error response, "
1393 << "code=" << code << "; killing connection.";
1394 set_state(STATE_FAILED);
1395 Destroy();
1396 }
1397
1371 } // namespace cricket 1398 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/p2p/base/turnport.h ('k') | webrtc/p2p/base/turnport_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698