diff options
author | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-08 06:12:41 +0000 |
---|---|---|
committer | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-08 06:12:41 +0000 |
commit | 93054cc1fb19b52ab35ead21f28baf46c55bbfb9 (patch) | |
tree | 147ba83f7c0d01ba4b93f1e5e04fb09ea3c58588 /net/socket/client_socket_pool_base.cc | |
parent | 896280751f9b58b33eafed60c0b3321755a0a3ac (diff) | |
download | chromium_src-93054cc1fb19b52ab35ead21f28baf46c55bbfb9.zip chromium_src-93054cc1fb19b52ab35ead21f28baf46c55bbfb9.tar.gz chromium_src-93054cc1fb19b52ab35ead21f28baf46c55bbfb9.tar.bz2 |
Revert "Revert an idle sockets change to trigger reliability bot. Will revert again soon."
Review URL: http://codereview.chromium.org/2761001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49146 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/socket/client_socket_pool_base.cc')
-rw-r--r-- | net/socket/client_socket_pool_base.cc | 77 |
1 files changed, 23 insertions, 54 deletions
diff --git a/net/socket/client_socket_pool_base.cc b/net/socket/client_socket_pool_base.cc index 594a858..80857e5 100644 --- a/net/socket/client_socket_pool_base.cc +++ b/net/socket/client_socket_pool_base.cc @@ -212,6 +212,23 @@ int ClientSocketPoolBaseHelper::RequestSocketInternal( CHECK(handle); Group& group = group_map_[group_name]; + // Can we make another active socket now? + if (ReachedMaxSocketsLimit() || + !group.HasAvailableSocketSlot(max_sockets_per_group_)) { + if (ReachedMaxSocketsLimit()) { + // 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. + may_have_stalled_group_ = true; + + request->net_log().AddEvent(NetLog::TYPE_SOCKET_POOL_STALLED_MAX_SOCKETS, + NULL); + } else { + request->net_log().AddEvent( + NetLog::TYPE_SOCKET_POOL_STALLED_MAX_SOCKETS_PER_GROUP, NULL); + } + return ERR_IO_PENDING; + } + // Try to reuse a socket. while (!group.idle_sockets.empty()) { IdleSocket idle_socket = group.idle_sockets.back(); @@ -229,26 +246,6 @@ int ClientSocketPoolBaseHelper::RequestSocketInternal( delete idle_socket.socket; } - // Can we make another active socket now? - if (!group.HasAvailableSocketSlot(max_sockets_per_group_)) { - request->net_log().AddEvent( - NetLog::TYPE_SOCKET_POOL_STALLED_MAX_SOCKETS_PER_GROUP, NULL); - return ERR_IO_PENDING; - } - - if (ReachedMaxSocketsLimit()) { - if (idle_socket_count() > 0) { - CloseOneIdleSocket(); - } 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. - may_have_stalled_group_ = true; - request->net_log().AddEvent( - NetLog::TYPE_SOCKET_POOL_STALLED_MAX_SOCKETS, NULL); - return ERR_IO_PENDING; - } - } - // See if we already have enough connect jobs or sockets that will be released // soon. if (group.HasReleasingSockets()) { @@ -535,14 +532,10 @@ void ClientSocketPoolBaseHelper::DoReleaseSocket(const std::string& group_name, int stalled_group_count = FindTopStalledGroup(&top_group, &top_group_name); if (stalled_group_count >= 1) { if (ReachedMaxSocketsLimit()) { - if (idle_socket_count() > 0) { - CloseOneIdleSocket(); - } else { - // We can't activate more sockets since we're already at our global - // limit. - may_have_stalled_group_ = true; - return; - } + // We can't activate more sockets since we're already at our global + // limit. + may_have_stalled_group_ = true; + return; } ProcessPendingRequest(top_group_name, top_group); @@ -680,10 +673,8 @@ void ClientSocketPoolBaseHelper::OnAvailableSocketSlot( (stalled_group_count == 1 && top_group->num_releasing_sockets == 0)) { may_have_stalled_group_ = false; } - if (stalled_group_count >= 1) { - CHECK_GE(1, idle_socket_count()); + if (stalled_group_count >= 1) ProcessPendingRequest(top_group_name, top_group); - } } else if (!group->pending_requests.empty()) { ProcessPendingRequest(group_name, group); // |group| may no longer be valid after this point. Be careful not to @@ -777,8 +768,7 @@ void ClientSocketPoolBaseHelper::CancelAllConnectJobs() { bool ClientSocketPoolBaseHelper::ReachedMaxSocketsLimit() const { // Each connecting socket will eventually connect and be handed out. - int total = handed_out_socket_count_ + connecting_socket_count_ + - idle_socket_count(); + int total = handed_out_socket_count_ + connecting_socket_count_; DCHECK_LE(total, max_sockets_); if (total < max_sockets_) return false; @@ -786,27 +776,6 @@ bool ClientSocketPoolBaseHelper::ReachedMaxSocketsLimit() const { return true; } -void ClientSocketPoolBaseHelper::CloseOneIdleSocket() { - CHECK_GT(idle_socket_count(), 0); - - for (GroupMap::iterator i = group_map_.begin(); i != group_map_.end(); ++i) { - Group& group = i->second; - - if (!group.idle_sockets.empty()) { - std::deque<IdleSocket>::iterator j = group.idle_sockets.begin(); - delete j->socket; - group.idle_sockets.erase(j); - DecrementIdleCount(); - if (group.IsEmpty()) - group_map_.erase(i); - - return; - } - } - - LOG(DFATAL) << "No idle socket found to close!."; -} - } // namespace internal } // namespace net |