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

Unified Diff: webrtc/p2p/base/port.cc

Issue 2184013003: Delay destroying a port if new connections are created and destroyed. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Created 4 years, 5 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
« no previous file with comments | « webrtc/p2p/base/port.h ('k') | webrtc/p2p/base/port_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/p2p/base/port.cc
diff --git a/webrtc/p2p/base/port.cc b/webrtc/p2p/base/port.cc
index b6173ebf45768be331c589631f81f9aee8ccbc80..535dd90f999efdc55cf25f6ca3a130d644b56d24 100644
--- a/webrtc/p2p/base/port.cc
+++ b/webrtc/p2p/base/port.cc
@@ -645,7 +645,7 @@ void Port::SendBindingErrorResponse(StunMessage* request,
}
void Port::OnMessage(rtc::Message *pmsg) {
- ASSERT(pmsg->message_id == MSG_DEAD);
+ ASSERT(pmsg->message_id == MSG_CHECK_DEAD);
if (dead()) {
Destroy();
}
@@ -702,12 +702,19 @@ void Port::OnConnectionDestroyed(Connection* conn) {
// On the controlled side, ports time out after all connections fail.
// Note: If a new connection is added after this message is posted, but it
// fails and is removed before kPortTimeoutDelay, then this message will
- // still cause the Port to be destroyed.
- if (dead()) {
- thread_->PostDelayed(RTC_FROM_HERE, timeout_delay_, this, MSG_DEAD);
+ // not cause the Port to be destroyed.
+ if (ice_role_ == ICEROLE_CONTROLLED && connections_.empty()) {
+ last_time_all_connections_removed_ = rtc::TimeMillis();
+ thread_->PostDelayed(RTC_FROM_HERE, timeout_delay_, this, MSG_CHECK_DEAD);
}
}
+bool Port::dead() const {
+ return ice_role_ == ICEROLE_CONTROLLED && connections_.empty() &&
+ rtc::TimeMillis() - last_time_all_connections_removed_ >=
+ timeout_delay_;
+}
+
void Port::Destroy() {
ASSERT(connections_.empty());
LOG_J(LS_INFO, this) << "Port deleted";
« no previous file with comments | « webrtc/p2p/base/port.h ('k') | webrtc/p2p/base/port_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698