| 163 | } |
| 164 | |
| 165 | void ClientCacheHelper::DestroyClient(ClientKey* client_key) { |
| 166 | DCHECK(*client_key != NULL) << "Trying to destroy NULL client"; |
| 167 | shared_ptr<ThriftClientImpl> client_impl; |
| 168 | ClientMap::iterator client; |
| 169 | { |
| 170 | lock_guard<mutex> lock(client_map_lock_); |
| 171 | client = client_map_.find(*client_key); |
| 172 | DCHECK(client != client_map_.end()); |
| 173 | client_impl = client->second; |
| 174 | } |
| 175 | VLOG(1) << "Broken Connection, destroy client for " << |
| 176 | TNetworkAddressToString(client_impl->address()); |
| 177 | |
| 178 | client_impl->Close(); |
| 179 | if (metrics_enabled_) total_clients_metric_->Increment(-1); |
| 180 | if (metrics_enabled_) clients_in_use_metric_->Increment(-1); |
| 181 | lock_guard<mutex> lock(client_map_lock_); |
| 182 | client_map_.erase(client); |
| 183 | *client_key = NULL; |
| 184 | } |
| 185 | |
| 186 | void ClientCacheHelper::CloseConnections(const TNetworkAddress& address) { |
| 187 | PerHostCache* cache; |