diff options
Diffstat (limited to 'net/base/tcp_client_socket_pool.cc')
-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); } |