summaryrefslogtreecommitdiffstats
path: root/net/socket/client_socket_pool_base.cc
diff options
context:
space:
mode:
authorwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-13 22:02:56 +0000
committerwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-13 22:02:56 +0000
commit42df4e8eba0ccd4dc81875482fe0786228b38702 (patch)
tree41912df99a194ebd43439bef5b1d17e240ab9ffd /net/socket/client_socket_pool_base.cc
parent148e47de6904b89adf7239e1f3bdb831cddcbf4c (diff)
downloadchromium_src-42df4e8eba0ccd4dc81875482fe0786228b38702.zip
chromium_src-42df4e8eba0ccd4dc81875482fe0786228b38702.tar.gz
chromium_src-42df4e8eba0ccd4dc81875482fe0786228b38702.tar.bz2
Revert r44150 and r43882.
r44150 is a fix for r43882. r43882 is a bugfix to include the idle sockets in the socket limit and close them when we hit the limit. Including the idle sockets in the socket limit check make us hit the socket limit more often, which exposed some bugs in the existing code. These two patches may also have introduced some separate crashes of their own (it's unclear from the stacktraces). I'm reverting them for now to mitigate the crashes. BUG=32817,41228 Review URL: http://codereview.chromium.org/1657001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44402 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/socket/client_socket_pool_base.cc')
-rw-r--r--net/socket/client_socket_pool_base.cc62
1 files changed, 17 insertions, 45 deletions
diff --git a/net/socket/client_socket_pool_base.cc b/net/socket/client_socket_pool_base.cc
index c635a20..7389532 100644
--- a/net/socket/client_socket_pool_base.cc
+++ b/net/socket/client_socket_pool_base.cc
@@ -182,6 +182,21 @@ 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);
+ } else {
+ request->net_log().AddEvent(NetLog::TYPE_SOCKET_POOL_STALLED_MAX_SOCKETS_PER_GROUP);
+ }
+ return ERR_IO_PENDING;
+ }
+
// Try to reuse a socket.
while (!group.idle_sockets.empty()) {
IdleSocket idle_socket = group.idle_sockets.back();
@@ -199,25 +214,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);
- 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);
- return ERR_IO_PENDING;
- }
- }
-
// See if we already have enough connect jobs or sockets that will be released
// soon.
if (group.HasReleasingSockets()) {
@@ -615,10 +611,8 @@ void ClientSocketPoolBaseHelper::OnAvailableSocketSlot(
int stalled_group_count = FindTopStalledGroup(&top_group, &top_group_name);
if (stalled_group_count <= 1)
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
@@ -707,33 +701,11 @@ 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_);
return total == max_sockets_;
}
-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;
- }
- }
-
- NOTREACHED();
-}
-
} // namespace internal
} // namespace net