diff options
author | wtc@chromium.org <wtc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-19 23:27:33 +0000 |
---|---|---|
committer | wtc@chromium.org <wtc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-19 23:27:33 +0000 |
commit | b2197853ee021e8b6d1c4f3c46e475da372b6980 (patch) | |
tree | 3429dcfc22d7f3ec683bbe2c1923b208d78adb26 /net/base/client_socket_pool.h | |
parent | 814c99861aa1116c588a63b20dd1b7a4f9a974e0 (diff) | |
download | chromium_src-b2197853ee021e8b6d1c4f3c46e475da372b6980.zip chromium_src-b2197853ee021e8b6d1c4f3c46e475da372b6980.tar.gz chromium_src-b2197853ee021e8b6d1c4f3c46e475da372b6980.tar.bz2 |
If an idle socket has received data unexpectedly, we can't
reuse it.
Add the IsConnectedAndIdle method, which returns true if the
connection is still alive and idle (hasn't received any data
unexpectedly).
R=eroman
BUG=4606
Review URL: http://codereview.chromium.org/21501
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10060 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/client_socket_pool.h')
-rw-r--r-- | net/base/client_socket_pool.h | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/net/base/client_socket_pool.h b/net/base/client_socket_pool.h index 764f859..cb43637 100644 --- a/net/base/client_socket_pool.h +++ b/net/base/client_socket_pool.h @@ -77,7 +77,7 @@ class ClientSocketPool : public base::RefCounted<ClientSocketPool> { ~ClientSocketPool(); // Closes all idle sockets if |force| is true. Else, only closes idle - // sockets that are disconnected or timed out. + // sockets that timed out or can't be reused. void CleanupIdleSockets(bool force); // Called when the number of idle sockets changes. @@ -88,7 +88,7 @@ class ClientSocketPool : public base::RefCounted<ClientSocketPool> { void DoReleaseSocket(const std::string& group_name, ClientSocketPtr* ptr); // Called when timer_ fires. This method scans the idle sockets removing - // sockets that are disconnected or timed out. + // sockets that timed out or can't be reused. void OnCleanupTimerFired() { CleanupIdleSockets(false); } @@ -105,8 +105,13 @@ class ClientSocketPool : public base::RefCounted<ClientSocketPool> { ClientSocketPtr* ptr; base::TimeTicks start_time; - // An idle socket should be removed if it is disconnected, or has been idle + // An idle socket should be removed if it can't be reused, or has been idle // for too long. |now| is the current time value (TimeTicks::Now()). + // + // An idle socket can't be reused if it is disconnected or has received + // data unexpectedly (hence no longer idle). The unread data would be + // mistaken for the beginning of the next response if we were to reuse the + // socket for a new request. bool ShouldCleanup(base::TimeTicks now) const; }; @@ -122,8 +127,8 @@ class ClientSocketPool : public base::RefCounted<ClientSocketPool> { typedef std::map<std::string, Group> GroupMap; GroupMap group_map_; - // Timer used to periodically prune idle sockets that are disconnected or - // timed out. + // Timer used to periodically prune idle sockets that timed out or can't be + // reused. base::RepeatingTimer<ClientSocketPool> timer_; // The total number of idle sockets in the system. @@ -131,7 +136,7 @@ class ClientSocketPool : public base::RefCounted<ClientSocketPool> { // The maximum number of sockets kept per group. int max_sockets_per_group_; - + DISALLOW_COPY_AND_ASSIGN(ClientSocketPool); }; |