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

Unified Diff: net/base/client_socket_pool.cc

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_pool.h ('k') | net/base/client_socket_pool_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/client_socket_pool.cc
===================================================================
--- net/base/client_socket_pool.cc (revision 10055)
+++ net/base/client_socket_pool.cc (working copy)
@@ -13,11 +13,12 @@
namespace {
-// The timeout value, in seconds, used to clean up disconnected idle sockets.
+// The timeout value, in seconds, used to clean up idle sockets that can't be
+// reused.
const int kCleanupInterval = 10;
// The maximum duration, in seconds, to keep idle persistent sockets alive.
-const int kIdleTimeout = 300; // 5 minutes.
+const int kIdleTimeout = 300; // 5 minutes.
} // namespace
@@ -54,12 +55,12 @@
group.active_socket_count++;
// Use idle sockets in LIFO order because they're more likely to be
- // still connected.
+ // still reusable.
while (!group.idle_sockets.empty()) {
IdleSocket idle_socket = group.idle_sockets.back();
group.idle_sockets.pop_back();
DecrementIdleCount();
- if ((*idle_socket.ptr)->IsConnected()) {
+ if ((*idle_socket.ptr)->IsConnectedAndIdle()) {
// We found one we can reuse!
handle->socket_ = idle_socket.ptr;
return OK;
@@ -103,9 +104,9 @@
}
bool ClientSocketPool::IdleSocket::ShouldCleanup(base::TimeTicks now) const {
- bool timed_out = (now - start_time) >=
+ bool timed_out = (now - start_time) >=
base::TimeDelta::FromSeconds(kIdleTimeout);
- return timed_out || !(*ptr)->IsConnected();
+ return timed_out || !(*ptr)->IsConnectedAndIdle();
}
void ClientSocketPool::CleanupIdleSockets(bool force) {
@@ -162,7 +163,7 @@
DCHECK(group.active_socket_count > 0);
group.active_socket_count--;
- bool can_reuse = ptr->get() && (*ptr)->IsConnected();
+ bool can_reuse = ptr->get() && (*ptr)->IsConnectedAndIdle();
if (can_reuse) {
IdleSocket idle_socket;
idle_socket.ptr = ptr;
« no previous file with comments | « net/base/client_socket_pool.h ('k') | net/base/client_socket_pool_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698