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

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

Issue 1737493004: Keep on sending stun binding requests on zero-cost networks. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 10 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/p2p/base/stunport.cc
diff --git a/webrtc/p2p/base/stunport.cc b/webrtc/p2p/base/stunport.cc
index 8f37dd5218bb745b5e06ab6d8b2574faefc9aa44..a2f722b91b730ec6db17b90df5095ceae8731549 100644
--- a/webrtc/p2p/base/stunport.cc
+++ b/webrtc/p2p/base/stunport.cc
@@ -29,6 +29,9 @@ const int RETRY_TIMEOUT = 50 * 1000; // ICE says 50 secs
// (in milliseconds) because the connection binding requests should keep
// the NAT binding alive.
const int KEEP_ALIVE_TIMEOUT = 2 * 60 * 1000; // 2 minutes
+// This maximum deadline is used for low cost networks in order to keep the NAT
+// binding alive on a backup connection.
+const uint32_t MAX_KEEP_ALIVE_DEADLINE = 0xFFFFFFFF;
// Handles a binding request sent to the STUN server.
class StunBindingRequest : public StunRequest {
@@ -397,8 +400,10 @@ void UDPPort::SendStunBindingRequest(const rtc::SocketAddress& stun_addr) {
} else if (socket_->GetState() == rtc::AsyncPacketSocket::STATE_BOUND) {
// Check if |server_addr_| is compatible with the port's ip.
if (IsCompatibleAddress(stun_addr)) {
- requests_.Send(new StunBindingRequest(this, stun_addr,
- rtc::Time() + KEEP_ALIVE_TIMEOUT));
+ uint32_t deadline = (network_cost() == 0)
juberti2 2016/02/26 01:53:41 I don't like the |deadline| terminology - it's rea
honghaiz3 2016/02/26 18:46:57 Added comments. Renamed it to keepalive_lifetime.
+ ? MAX_KEEP_ALIVE_DEADLINE
+ : rtc::Time() + KEEP_ALIVE_TIMEOUT;
+ requests_.Send(new StunBindingRequest(this, stun_addr, deadline));
} else {
// Since we can't send stun messages to the server, we should mark this
// port ready.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698