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

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

Issue 1371623003: Delete a connection only if it has timed out on writing and not receiving for 10 seconds. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc@master
Patch Set: Rename a test Created 5 years, 3 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/p2ptransportchannel_unittest.cc ('k') | webrtc/p2p/base/port.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/p2p/base/port.h
diff --git a/webrtc/p2p/base/port.h b/webrtc/p2p/base/port.h
index 47903be05b55753b063e6bc8630946d8938e59a1..4616963aa0a998ced683c6212de84d7e51145c49 100644
--- a/webrtc/p2p/base/port.h
+++ b/webrtc/p2p/base/port.h
@@ -50,9 +50,9 @@ extern const char TCPTYPE_ACTIVE_STR[];
extern const char TCPTYPE_PASSIVE_STR[];
extern const char TCPTYPE_SIMOPEN_STR[];
-// If a connection does not receive anything for this long, it is considered
-// dead.
-const uint32 DEAD_CONNECTION_RECEIVE_TIMEOUT = 30 * 1000; // 30 seconds.
+// The minimum time we will wait before destroying a connection after creating
+// it.
+const uint32 MIN_CONNECTION_LIFETIME = 10 * 1000; // 10 seconds.
// The timeout duration when a connection does not receive anything.
const uint32 WEAK_CONNECTION_RECEIVE_TIMEOUT = 2500; // 2.5 seconds
@@ -435,8 +435,13 @@ class Connection : public rtc::MessageHandler,
// Determines whether the connection has finished connecting. This can only
// be false for TCP connections.
bool connected() const { return connected_; }
-
- bool Weak() const { return !(writable() && receiving() && connected()); }
+ bool weak() const { return !(writable() && receiving() && connected()); }
+ bool active() const {
+ // TODO(honghaiz): Move from using |write_state_| to using |pruned_|.
+ return write_state_ != STATE_WRITE_TIMEOUT;
+ }
+ // A connection is dead if it can be safely deleted.
+ bool dead(uint32 now) const;
// Estimate of the round-trip time over this connection.
uint32 rtt() const { return rtt_; }
@@ -572,9 +577,6 @@ class Connection : public rtc::MessageHandler,
void set_state(State state);
void set_connected(bool value);
- // Checks if this connection is useless, and hence, should be destroyed.
- void CheckTimeout();
-
void OnMessage(rtc::Message *pmsg);
Port* port_;
@@ -615,6 +617,7 @@ class Connection : public rtc::MessageHandler,
State state_;
// Time duration to switch from receiving to not receiving.
uint32 receiving_timeout_;
+ uint32 time_created_ms_;
friend class Port;
friend class ConnectionRequest;
« no previous file with comments | « webrtc/p2p/base/p2ptransportchannel_unittest.cc ('k') | webrtc/p2p/base/port.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698