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

Unified Diff: net/base/client_socket_pool.h

Issue 21501: If an idle socket has received data unexpectedly, we... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Final upload before checkin. Created 11 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 | « net/base/client_socket.h ('k') | net/base/client_socket_pool.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/client_socket_pool.h
===================================================================
--- net/base/client_socket_pool.h (revision 10055)
+++ net/base/client_socket_pool.h (working copy)
@@ -77,7 +77,7 @@
~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 @@
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 @@
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 @@
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 @@
// The maximum number of sockets kept per group.
int max_sockets_per_group_;
-
+
DISALLOW_COPY_AND_ASSIGN(ClientSocketPool);
};
« no previous file with comments | « net/base/client_socket.h ('k') | net/base/client_socket_pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698