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

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

Issue 1415313004: Destroy a Connection if a CreatePermission request fails. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Switching to "FailAndDestroy" method on Connection. Created 5 years 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/turnport.h » ('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 988 matching lines...) Expand 10 before | Expand all | Expand 10 after
999 requests_.Clear(); 999 requests_.Clear();
1000 set_write_state(STATE_WRITE_TIMEOUT); 1000 set_write_state(STATE_WRITE_TIMEOUT);
1001 } 1001 }
1002 } 1002 }
1003 1003
1004 void Connection::Destroy() { 1004 void Connection::Destroy() {
1005 LOG_J(LS_VERBOSE, this) << "Connection destroyed"; 1005 LOG_J(LS_VERBOSE, this) << "Connection destroyed";
1006 port_->thread()->Post(this, MSG_DELETE); 1006 port_->thread()->Post(this, MSG_DELETE);
1007 } 1007 }
1008 1008
1009 void Connection::FailAndDestroy() {
1010 set_state(Connection::STATE_FAILED);
1011 Destroy();
1012 }
1013
1009 void Connection::PrintPingsSinceLastResponse(std::string* s, size_t max) { 1014 void Connection::PrintPingsSinceLastResponse(std::string* s, size_t max) {
1010 std::ostringstream oss; 1015 std::ostringstream oss;
1011 oss << std::boolalpha; 1016 oss << std::boolalpha;
1012 if (pings_since_last_response_.size() > max) { 1017 if (pings_since_last_response_.size() > max) {
1013 for (size_t i = 0; i < max; i++) { 1018 for (size_t i = 0; i < max; i++) {
1014 const SentPing& ping = pings_since_last_response_[i]; 1019 const SentPing& ping = pings_since_last_response_[i];
1015 oss << rtc::hex_encode(ping.id) << " "; 1020 oss << rtc::hex_encode(ping.id) << " ";
1016 } 1021 }
1017 oss << "... " << (pings_since_last_response_.size() - max) << " more"; 1022 oss << "... " << (pings_since_last_response_.size() - max) << " more";
1018 } else { 1023 } else {
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
1241 error_code == STUN_ERROR_UNAUTHORIZED) { 1246 error_code == STUN_ERROR_UNAUTHORIZED) {
1242 // Recoverable error, retry 1247 // Recoverable error, retry
1243 } else if (error_code == STUN_ERROR_STALE_CREDENTIALS) { 1248 } else if (error_code == STUN_ERROR_STALE_CREDENTIALS) {
1244 // Race failure, retry 1249 // Race failure, retry
1245 } else if (error_code == STUN_ERROR_ROLE_CONFLICT) { 1250 } else if (error_code == STUN_ERROR_ROLE_CONFLICT) {
1246 HandleRoleConflictFromPeer(); 1251 HandleRoleConflictFromPeer();
1247 } else { 1252 } else {
1248 // This is not a valid connection. 1253 // This is not a valid connection.
1249 LOG_J(LS_ERROR, this) << "Received STUN error response, code=" 1254 LOG_J(LS_ERROR, this) << "Received STUN error response, code="
1250 << error_code << "; killing connection"; 1255 << error_code << "; killing connection";
1251 set_state(STATE_FAILED); 1256 FailAndDestroy();
1252 Destroy();
1253 } 1257 }
1254 } 1258 }
1255 1259
1256 void Connection::OnConnectionRequestTimeout(ConnectionRequest* request) { 1260 void Connection::OnConnectionRequestTimeout(ConnectionRequest* request) {
1257 // Log at LS_INFO if we miss a ping on a writable connection. 1261 // Log at LS_INFO if we miss a ping on a writable connection.
1258 rtc::LoggingSeverity sev = writable() ? rtc::LS_INFO : rtc::LS_VERBOSE; 1262 rtc::LoggingSeverity sev = writable() ? rtc::LS_INFO : rtc::LS_VERBOSE;
1259 LOG_JV(sev, this) << "Timing-out STUN ping " 1263 LOG_JV(sev, this) << "Timing-out STUN ping "
1260 << rtc::hex_encode(request->id()) 1264 << rtc::hex_encode(request->id())
1261 << " after " << request->Elapsed() << " ms"; 1265 << " after " << request->Elapsed() << " ms";
1262 } 1266 }
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
1389 local_candidate().address())); 1393 local_candidate().address()));
1390 1394
1391 // Change the local candidate of this Connection to the new prflx candidate. 1395 // Change the local candidate of this Connection to the new prflx candidate.
1392 local_candidate_index_ = port_->AddPrflxCandidate(new_local_candidate); 1396 local_candidate_index_ = port_->AddPrflxCandidate(new_local_candidate);
1393 1397
1394 // SignalStateChange to force a re-sort in P2PTransportChannel as this 1398 // SignalStateChange to force a re-sort in P2PTransportChannel as this
1395 // Connection's local candidate has changed. 1399 // Connection's local candidate has changed.
1396 SignalStateChange(this); 1400 SignalStateChange(this);
1397 } 1401 }
1398 1402
1399 ProxyConnection::ProxyConnection(Port* port, size_t index, 1403 ProxyConnection::ProxyConnection(Port* port,
1400 const Candidate& candidate) 1404 size_t index,
1401 : Connection(port, index, candidate), error_(0) { 1405 const Candidate& remote_candidate)
1402 } 1406 : Connection(port, index, remote_candidate) {}
1403 1407
1404 int ProxyConnection::Send(const void* data, size_t size, 1408 int ProxyConnection::Send(const void* data, size_t size,
1405 const rtc::PacketOptions& options) { 1409 const rtc::PacketOptions& options) {
1406 if (write_state_ == STATE_WRITE_INIT || write_state_ == STATE_WRITE_TIMEOUT) { 1410 if (write_state_ == STATE_WRITE_INIT || write_state_ == STATE_WRITE_TIMEOUT) {
1407 error_ = EWOULDBLOCK; 1411 error_ = EWOULDBLOCK;
1408 return SOCKET_ERROR; 1412 return SOCKET_ERROR;
1409 } 1413 }
1410 sent_packets_total_++; 1414 sent_packets_total_++;
1411 int sent = port_->SendTo(data, size, remote_candidate_.address(), 1415 int sent = port_->SendTo(data, size, remote_candidate_.address(),
1412 options, true); 1416 options, true);
1413 if (sent <= 0) { 1417 if (sent <= 0) {
1414 ASSERT(sent < 0); 1418 ASSERT(sent < 0);
1415 error_ = port_->GetError(); 1419 error_ = port_->GetError();
1416 sent_packets_discarded_++; 1420 sent_packets_discarded_++;
1417 } else { 1421 } else {
1418 send_rate_tracker_.AddSamples(sent); 1422 send_rate_tracker_.AddSamples(sent);
1419 } 1423 }
1420 return sent; 1424 return sent;
1421 } 1425 }
1422 1426
1423 } // namespace cricket 1427 } // namespace cricket
OLDNEW
« no previous file with comments | « webrtc/p2p/base/port.h ('k') | webrtc/p2p/base/turnport.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698