Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(208)

Side by Side Diff: net/socket/client_socket_pool_base.cc

Issue 150196: Fix leak on connection error. (Closed)
Patch Set: Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/socket/client_socket_pool_base.h" 5 #include "net/socket/client_socket_pool_base.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/message_loop.h" 8 #include "base/message_loop.h"
9 #include "base/stl_util-inl.h" 9 #include "base/stl_util-inl.h"
10 #include "base/time.h" 10 #include "base/time.h"
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 296
297 RequestMap* request_map = &group.connecting_requests; 297 RequestMap* request_map = &group.connecting_requests;
298 298
299 RequestMap::iterator it = request_map->find(job->key_handle()); 299 RequestMap::iterator it = request_map->find(job->key_handle());
300 CHECK(it != request_map->end()); 300 CHECK(it != request_map->end());
301 ClientSocketHandle* const handle = it->second.handle; 301 ClientSocketHandle* const handle = it->second.handle;
302 CompletionCallback* const callback = it->second.callback; 302 CompletionCallback* const callback = it->second.callback;
303 request_map->erase(it); 303 request_map->erase(it);
304 DCHECK_EQ(handle, job->key_handle()); 304 DCHECK_EQ(handle, job->key_handle());
305 305
306 ClientSocket* const socket = job->ReleaseSocket(); 306 scoped_ptr<ClientSocket> socket(job->ReleaseSocket());
307 RemoveConnectJob(job->key_handle()); 307 RemoveConnectJob(job->key_handle());
308 308
309 if (result != OK) { 309 if (result != OK) {
310 callback->Run(result); // |group| is not necessarily valid after this. 310 callback->Run(result); // |group| is not necessarily valid after this.
311 // |group| may be invalid after the callback, we need to search 311 // |group| may be invalid after the callback, we need to search
312 // |group_map_| again. 312 // |group_map_| again.
313 MaybeOnAvailableSocketSlot(group_name); 313 MaybeOnAvailableSocketSlot(group_name);
314 } else { 314 } else {
315 HandOutSocket(socket, false /* not reused */, handle, &group); 315 HandOutSocket(socket.release(), false /* not reused */, handle, &group);
316 callback->Run(result); 316 callback->Run(result);
317 } 317 }
318 } 318 }
319 319
320 void ClientSocketPoolBase::RemoveConnectJob( 320 void ClientSocketPoolBase::RemoveConnectJob(
321 const ClientSocketHandle* handle) { 321 const ClientSocketHandle* handle) {
322 ConnectJobMap::iterator it = connect_job_map_.find(handle); 322 ConnectJobMap::iterator it = connect_job_map_.find(handle);
323 CHECK(it != connect_job_map_.end()); 323 CHECK(it != connect_job_map_.end());
324 delete it->second; 324 delete it->second;
325 connect_job_map_.erase(it); 325 connect_job_map_.erase(it);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 bool reused, 370 bool reused,
371 ClientSocketHandle* handle, 371 ClientSocketHandle* handle,
372 Group* group) { 372 Group* group) {
373 DCHECK(socket); 373 DCHECK(socket);
374 handle->set_socket(socket); 374 handle->set_socket(socket);
375 handle->set_is_reused(reused); 375 handle->set_is_reused(reused);
376 group->active_socket_count++; 376 group->active_socket_count++;
377 } 377 }
378 378
379 } // namespace net 379 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698