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

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

Issue 10083024: Revert 132478 - Attempt to close idle connections in higher layer socket pools when a lower layer p… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 8 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 | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <math.h> 7 #include <math.h>
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/format_macros.h" 9 #include "base/format_macros.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 // NOTE(mmenke): Wonder if we really need different code for each case 362 // NOTE(mmenke): Wonder if we really need different code for each case
363 // here. Only reason for them now seems to be preconnects. 363 // here. Only reason for them now seems to be preconnects.
364 if (idle_socket_count() > 0) { 364 if (idle_socket_count() > 0) {
365 // There's an idle socket in this pool. Either that's because there's 365 // There's an idle socket in this pool. Either that's because there's
366 // still one in this group, but we got here due to preconnecting bypassing 366 // still one in this group, but we got here due to preconnecting bypassing
367 // idle sockets, or because there's an idle socket in another group. 367 // idle sockets, or because there's an idle socket in another group.
368 bool closed = CloseOneIdleSocketExceptInGroup(group); 368 bool closed = CloseOneIdleSocketExceptInGroup(group);
369 if (preconnecting && !closed) 369 if (preconnecting && !closed)
370 return ERR_PRECONNECT_MAX_SOCKET_LIMIT; 370 return ERR_PRECONNECT_MAX_SOCKET_LIMIT;
371 } else { 371 } else {
372 do { 372 // We could check if we really have a stalled group here, but it requires
373 if (!CloseOneIdleConnectionInLayeredPool()) { 373 // a scan of all groups, so just flip a flag here, and do the check later.
374 // We could check if we really have a stalled group here, but it 374 request->net_log().AddEvent(
375 // requires a scan of all groups, so return ERR_IO_PENDING, and do 375 NetLog::TYPE_SOCKET_POOL_STALLED_MAX_SOCKETS, NULL);
376 // the check later. 376 return ERR_IO_PENDING;
377 request->net_log().AddEvent(
378 NetLog::TYPE_SOCKET_POOL_STALLED_MAX_SOCKETS, NULL);
379 return ERR_IO_PENDING;
380 }
381 } while (ReachedMaxSocketsLimit());
382
383 // It is possible that CloseOneIdleConnectionInLayeredPool() has deleted
384 // our Group (see http://crbug.com/109876), so look it up again
385 // to be safe.
386 group = GetOrCreateGroup(group_name);
387 } 377 }
388 } 378 }
389 379
390 // We couldn't find a socket to reuse, and there's space to allocate one, 380 // We couldn't find a socket to reuse, and there's space to allocate one,
391 // so allocate and connect a new one. 381 // so allocate and connect a new one.
392 scoped_ptr<ConnectJob> connect_job( 382 scoped_ptr<ConnectJob> connect_job(
393 connect_job_factory_->NewConnectJob(group_name, *request, this)); 383 connect_job_factory_->NewConnectJob(group_name, *request, this));
394 384
395 connect_job->Initialize(preconnecting); 385 connect_job->Initialize(preconnecting);
396 int rv = connect_job->Connect(); 386 int rv = connect_job->Connect();
(...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after
1223 // Delete active jobs. 1213 // Delete active jobs.
1224 STLDeleteElements(&jobs_); 1214 STLDeleteElements(&jobs_);
1225 1215
1226 // Cancel pending backup job. 1216 // Cancel pending backup job.
1227 weak_factory_.InvalidateWeakPtrs(); 1217 weak_factory_.InvalidateWeakPtrs();
1228 } 1218 }
1229 1219
1230 } // namespace internal 1220 } // namespace internal
1231 1221
1232 } // namespace net 1222 } // 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