diff options
author | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-18 03:36:09 +0000 |
---|---|---|
committer | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-18 03:36:09 +0000 |
commit | 9fc467cc93b00d02ac9f2cc2f25446505aef3a82 (patch) | |
tree | cda4d6467a0d4c271a808e40587b88776209c02e /net | |
parent | 7387509129d02968481c9cd912ab60c79bd6deea (diff) | |
download | chromium_src-9fc467cc93b00d02ac9f2cc2f25446505aef3a82.zip chromium_src-9fc467cc93b00d02ac9f2cc2f25446505aef3a82.tar.gz chromium_src-9fc467cc93b00d02ac9f2cc2f25446505aef3a82.tar.bz2 |
Add more CHECKs to ClientSocketPoolBase.
BUG=http://crbug.com/14395
Review URL: http://codereview.chromium.org/131017
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18683 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/base/tcp_client_socket_pool.cc | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/net/base/tcp_client_socket_pool.cc b/net/base/tcp_client_socket_pool.cc index b8bb5c6..c4b97b8 100644 --- a/net/base/tcp_client_socket_pool.cc +++ b/net/base/tcp_client_socket_pool.cc @@ -186,6 +186,7 @@ int ClientSocketPoolBase::RequestSocket( handle->set_socket(idle_socket.socket); handle->set_is_reused(true); group.sockets_handed_out_count++; + CHECK(group.sockets_handed_out_count <= group.active_socket_count); CheckSocketCounts(group); return OK; } @@ -212,6 +213,7 @@ int ClientSocketPoolBase::RequestSocket( void ClientSocketPoolBase::CancelRequest(const std::string& group_name, const ClientSocketHandle* handle) { + CHECK(handle); CHECK(ContainsKey(group_map_, group_name)); Group& group = group_map_[group_name]; @@ -231,19 +233,21 @@ void ClientSocketPoolBase::CancelRequest(const std::string& group_name, CHECK(ContainsKey(group.connecting_requests, handle)); RequestMap::iterator map_it = group.connecting_requests.find(handle); - if (map_it != group.connecting_requests.end()) { - RemoveConnectingSocket(handle); + RemoveConnectingSocket(handle); - group.connecting_requests.erase(map_it); - group.active_socket_count--; + CheckSocketCounts(group); + group.connecting_requests.erase(map_it); + group.active_socket_count--; + CheckSocketCounts(group); - // Delete group if no longer needed. - if (group.active_socket_count == 0 && group.idle_sockets.empty()) { - CHECK(group.pending_requests.empty()); - CHECK(group.connecting_requests.empty()); - group_map_.erase(group_name); - return; - } + // Delete group if no longer needed. + if (group.active_socket_count == 0 && group.idle_sockets.empty()) { + CHECK(group.pending_requests.empty()); + CHECK(group.sockets_handed_out_count == 0); + CHECK(group.connecting_requests.size() == 0); + CHECK(group.connecting_requests.empty()); + group_map_.erase(group_name); + return; } CheckSocketCounts(group); @@ -370,6 +374,7 @@ void ClientSocketPoolBase::DoReleaseSocket(const std::string& group_name, group.active_socket_count--; group.sockets_handed_out_count--; + CHECK(group.sockets_handed_out_count >= 0); const bool can_reuse = socket->IsConnectedAndIdle(); if (can_reuse) { @@ -459,6 +464,7 @@ CompletionCallback* ClientSocketPoolBase::OnConnectingRequestComplete( request.handle->set_socket(socket); request.handle->set_is_reused(false); group.sockets_handed_out_count++; + CHECK(group.sockets_handed_out_count <= group.active_socket_count); CheckSocketCounts(group); } |