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

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

Issue 5523001: Fix ClientSocketPoolBaseHelper preconnect crasher. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add NOTREACHED(). Created 10 years 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | net/socket/client_socket_pool_base_unittest.cc » ('j') | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/format_macros.h" 8 #include "base/format_macros.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/metrics/stats_counters.h" 10 #include "base/metrics/stats_counters.h"
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 num_sockets = max_sockets_per_group_; 236 num_sockets = max_sockets_per_group_;
237 } 237 }
238 238
239 request.net_log().BeginEvent( 239 request.net_log().BeginEvent(
240 NetLog::TYPE_SOCKET_POOL_CONNECTING_N_SOCKETS, 240 NetLog::TYPE_SOCKET_POOL_CONNECTING_N_SOCKETS,
241 make_scoped_refptr(new NetLogIntegerParameter( 241 make_scoped_refptr(new NetLogIntegerParameter(
242 "num_sockets", num_sockets))); 242 "num_sockets", num_sockets)));
243 243
244 Group* group = GetOrCreateGroup(group_name); 244 Group* group = GetOrCreateGroup(group_name);
245 245
246 // RequestSocketsInternal() may delete the group.
247 bool deleted_group = false;
248
246 for (int num_iterations_left = num_sockets; 249 for (int num_iterations_left = num_sockets;
247 group->NumActiveSocketSlots() < num_sockets && 250 group->NumActiveSocketSlots() < num_sockets &&
248 num_iterations_left > 0 ; num_iterations_left--) { 251 num_iterations_left > 0 ; num_iterations_left--) {
249 int rv = RequestSocketInternal(group_name, &request); 252 int rv = RequestSocketInternal(group_name, &request);
250 if (rv < 0 && rv != ERR_IO_PENDING) { 253 if (rv < 0 && rv != ERR_IO_PENDING) {
251 // We're encountering a synchronous error. Give up. 254 // We're encountering a synchronous error. Give up.
255 if (!ContainsKey(group_map_, group_name))
256 deleted_group = true;
257 break;
258 }
259 if (!ContainsKey(group_map_, group_name)) {
260 // Unexpected. The group should only be getting deleted on synchronous
261 // error.
262 NOTREACHED();
263 deleted_group = true;
252 break; 264 break;
253 } 265 }
254 } 266 }
255 267
256 if (group->IsEmpty()) 268 if (!deleted_group && group->IsEmpty())
257 RemoveGroup(group_name); 269 RemoveGroup(group_name);
258 270
259 request.net_log().EndEvent( 271 request.net_log().EndEvent(
260 NetLog::TYPE_SOCKET_POOL_CONNECTING_N_SOCKETS, NULL); 272 NetLog::TYPE_SOCKET_POOL_CONNECTING_N_SOCKETS, NULL);
261 } 273 }
262 274
263 int ClientSocketPoolBaseHelper::RequestSocketInternal( 275 int ClientSocketPoolBaseHelper::RequestSocketInternal(
264 const std::string& group_name, 276 const std::string& group_name,
265 const Request* request) { 277 const Request* request) {
266 DCHECK_GE(request->priority(), 0); 278 DCHECK_GE(request->priority(), 0);
(...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after
1047 // Delete active jobs. 1059 // Delete active jobs.
1048 STLDeleteElements(&jobs_); 1060 STLDeleteElements(&jobs_);
1049 1061
1050 // Cancel pending backup job. 1062 // Cancel pending backup job.
1051 method_factory_.RevokeAll(); 1063 method_factory_.RevokeAll();
1052 } 1064 }
1053 1065
1054 } // namespace internal 1066 } // namespace internal
1055 1067
1056 } // namespace net 1068 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/socket/client_socket_pool_base_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698