Index: net/socket/client_socket_pool_base.cc |
diff --git a/net/socket/client_socket_pool_base.cc b/net/socket/client_socket_pool_base.cc |
index 02ac58710b5a6e52abbd4ef3c2d5bb7c0dbb4bbd..b08d1c87717d5b1ebd69a160a8f7a6a95bb2e1c5 100644 |
--- a/net/socket/client_socket_pool_base.cc |
+++ b/net/socket/client_socket_pool_base.cc |
@@ -286,7 +286,9 @@ int ClientSocketPoolBaseHelper::RequestSocketInternal( |
if (ReachedMaxSocketsLimit()) { |
if (idle_socket_count() > 0) { |
- CloseOneIdleSocket(); |
+ bool closed = CloseOneIdleSocketExceptInGroup(group); |
+ if (preconnecting && !closed) |
+ return ERR_PRECONNECT_MAX_SOCKET_LIMIT; |
} else { |
// We could check if we really have a stalled group here, but it requires |
// a scan of all groups, so just flip a flag here, and do the check later. |
@@ -928,10 +930,17 @@ bool ClientSocketPoolBaseHelper::ReachedMaxSocketsLimit() const { |
} |
void ClientSocketPoolBaseHelper::CloseOneIdleSocket() { |
+ CloseOneIdleSocketExceptInGroup(NULL); |
+} |
+ |
+bool ClientSocketPoolBaseHelper::CloseOneIdleSocketExceptInGroup( |
+ const Group* exception_group) { |
CHECK_GT(idle_socket_count(), 0); |
for (GroupMap::iterator i = group_map_.begin(); i != group_map_.end(); ++i) { |
Group* group = i->second; |
+ if (exception_group == group) |
+ continue; |
std::list<IdleSocket>* idle_sockets = group->mutable_idle_sockets(); |
if (!idle_sockets->empty()) { |
@@ -941,11 +950,14 @@ void ClientSocketPoolBaseHelper::CloseOneIdleSocket() { |
if (group->IsEmpty()) |
RemoveGroup(i); |
- return; |
+ return true; |
} |
} |
- LOG(DFATAL) << "No idle socket found to close!."; |
+ if (!exception_group) |
+ LOG(DFATAL) << "No idle socket found to close!."; |
+ |
+ return false; |
} |
void ClientSocketPoolBaseHelper::InvokeUserCallbackLater( |