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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: webrtc/p2p/base/turnport.cc
diff --git a/webrtc/p2p/base/turnport.cc b/webrtc/p2p/base/turnport.cc
index 3fdcac5f31b5804d094d8fe6e8a5891f7a8dd94e..b8360c31d494c50d7f0ec97c356a7f95c48e13b2 100644
--- a/webrtc/p2p/base/turnport.cc
+++ b/webrtc/p2p/base/turnport.cc
@@ -445,7 +445,7 @@ Connection* TurnPort::CreateConnection(const Candidate& address,
// and TURN candidate later.
for (size_t index = 0; index < Candidates().size(); ++index) {
if (Candidates()[index].type() == RELAY_PORT_TYPE) {
- ProxyConnection* conn = new ProxyConnection(this, index, address);
+ TurnConnection* conn = new TurnConnection(this, index, address);
conn->SignalDestroyed.connect(this, &TurnPort::OnConnectionDestroyed);
AddConnection(conn);
return conn;
@@ -1368,4 +1368,30 @@ void TurnEntry::OnChannelBindError(StunMessage* response, int code) {
}
}
+TurnConnection::TurnConnection(TurnPort* port,
+ size_t index,
+ const Candidate& remote_candidate)
+ : ProxyConnection(port, index, remote_candidate), turn_port_(port) {
+ turn_port_->SignalCreatePermissionResult.connect(
+ this, &TurnConnection::OnCreatePermissionResult);
+}
+
+TurnConnection::~TurnConnection() {
+ turn_port_->SignalCreatePermissionResult.disconnect(this);
+}
+
+void TurnConnection::OnCreatePermissionResult(
+ TurnPort* port,
+ const rtc::SocketAddress& remote_address,
+ int code) {
+ RTC_DCHECK(port == turn_port_);
+ if (remote_address != remote_candidate_.address() || code == 0) {
+ return;
+ }
+ LOG_J(LS_ERROR, this) << "Received TURN CreatePermission error response, "
+ << "code=" << code << "; killing connection.";
+ set_state(STATE_FAILED);
+ Destroy();
+}
+
} // namespace cricket

Powered by Google App Engine
This is Rietveld 408576698