| Index: webrtc/p2p/base/turnport.cc
|
| diff --git a/webrtc/p2p/base/turnport.cc b/webrtc/p2p/base/turnport.cc
|
| index 40368110e398a1edabfa3a5397ca2d8ad38b333d..ff0c2922de28334f285e4592aefb9dc78d6db4ad 100644
|
| --- a/webrtc/p2p/base/turnport.cc
|
| +++ b/webrtc/p2p/base/turnport.cc
|
| @@ -449,7 +449,7 @@
|
| return NULL;
|
| }
|
|
|
| - if (state_ == STATE_DISCONNECTED || state_ == STATE_RECEIVEONLY) {
|
| + if (state_ == STATE_DISCONNECTED) {
|
| return NULL;
|
| }
|
|
|
| @@ -469,10 +469,10 @@
|
| return NULL;
|
| }
|
|
|
| -bool TurnPort::FailAndPruneConnection(const rtc::SocketAddress& address) {
|
| +bool TurnPort::DestroyConnection(const rtc::SocketAddress& address) {
|
| Connection* conn = GetConnection(address);
|
| if (conn != nullptr) {
|
| - conn->FailAndPrune();
|
| + conn->Destroy();
|
| return true;
|
| }
|
| return false;
|
| @@ -561,7 +561,7 @@
|
|
|
| if (state_ == STATE_DISCONNECTED) {
|
| LOG_J(LS_WARNING, this)
|
| - << "Received TURN message while the TURN port is disconnected";
|
| + << "Received TURN message while the Turn port is disconnected";
|
| return false;
|
| }
|
|
|
| @@ -739,20 +739,11 @@
|
| thread()->Post(RTC_FROM_HERE, this, MSG_ALLOCATE_ERROR);
|
| }
|
|
|
| -void TurnPort::OnRefreshError() {
|
| - // Need to clear the requests asynchronously because otherwise, the refresh
|
| +void TurnPort::OnTurnRefreshError() {
|
| + // Need to Close the port asynchronously because otherwise, the refresh
|
| // request may be deleted twice: once at the end of the message processing
|
| - // and the other in HandleRefreshError().
|
| + // and the other in Close().
|
| thread()->Post(RTC_FROM_HERE, this, MSG_REFRESH_ERROR);
|
| -}
|
| -
|
| -void TurnPort::HandleRefreshError() {
|
| - request_manager_.Clear();
|
| - state_ = STATE_RECEIVEONLY;
|
| - // Fail and prune all connections; stop sending data.
|
| - for (auto kv : connections()) {
|
| - kv.second->FailAndPrune();
|
| - }
|
| }
|
|
|
| void TurnPort::Close() {
|
| @@ -777,7 +768,7 @@
|
| OnAllocateMismatch();
|
| break;
|
| case MSG_REFRESH_ERROR:
|
| - HandleRefreshError();
|
| + Close();
|
| break;
|
| case MSG_TRY_ALTERNATE_SERVER:
|
| if (server_address().proto == PROTO_UDP) {
|
| @@ -1286,14 +1277,14 @@
|
| << ", id=" << rtc::hex_encode(id())
|
| << ", code=" << error_code->code()
|
| << ", rtt=" << Elapsed();
|
| - port_->OnRefreshError();
|
| + port_->OnTurnRefreshError();
|
| port_->SignalTurnRefreshResult(port_, error_code->code());
|
| }
|
| }
|
|
|
| void TurnRefreshRequest::OnTimeout() {
|
| LOG_J(LS_WARNING, port_) << "TURN refresh timeout " << rtc::hex_encode(id());
|
| - port_->OnRefreshError();
|
| + port_->OnTurnRefreshError();
|
| }
|
|
|
| TurnCreatePermissionRequest::TurnCreatePermissionRequest(
|
| @@ -1500,18 +1491,20 @@
|
| SendCreatePermissionRequest(0);
|
| }
|
| } else {
|
| - bool found = port_->FailAndPruneConnection(ext_addr_);
|
| - if (found) {
|
| - LOG(LS_ERROR) << "Received TURN CreatePermission error response, "
|
| - << "code=" << code << "; pruned connection.";
|
| - }
|
| + port_->DestroyConnection(ext_addr_);
|
| // Send signal with error code.
|
| port_->SignalCreatePermissionResult(port_, ext_addr_, code);
|
| + Connection* c = port_->GetConnection(ext_addr_);
|
| + if (c) {
|
| + LOG_J(LS_ERROR, c) << "Received TURN CreatePermission error response, "
|
| + << "code=" << code << "; killing connection.";
|
| + c->FailAndDestroy();
|
| + }
|
| }
|
| }
|
|
|
| void TurnEntry::OnCreatePermissionTimeout() {
|
| - port_->FailAndPruneConnection(ext_addr_);
|
| + port_->DestroyConnection(ext_addr_);
|
| }
|
|
|
| void TurnEntry::OnChannelBindSuccess() {
|
| @@ -1523,8 +1516,8 @@
|
|
|
| void TurnEntry::OnChannelBindError(StunMessage* response, int code) {
|
| // If the channel bind fails due to errors other than STATE_NONCE,
|
| - // we will fail and prune the connection and rely on ICE restart to
|
| - // re-establish a new connection if needed.
|
| + // we just destroy the connection and rely on ICE restart to re-establish
|
| + // the connection.
|
| if (code == STUN_ERROR_STALE_NONCE) {
|
| if (port_->UpdateNonce(response)) {
|
| // Send channel bind request with fresh nonce.
|
| @@ -1532,11 +1525,11 @@
|
| }
|
| } else {
|
| state_ = STATE_UNBOUND;
|
| - port_->FailAndPruneConnection(ext_addr_);
|
| + port_->DestroyConnection(ext_addr_);
|
| }
|
| }
|
| void TurnEntry::OnChannelBindTimeout() {
|
| state_ = STATE_UNBOUND;
|
| - port_->FailAndPruneConnection(ext_addr_);
|
| + port_->DestroyConnection(ext_addr_);
|
| }
|
| } // namespace cricket
|
|
|