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

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

Issue 1708009: Fix case where backup socket jobs ignored the socket limits.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 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 | 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) 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/stats_counters.h" 10 #include "base/stats_counters.h"
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 const std::string& group_name) { 291 const std::string& group_name) {
292 CHECK(ContainsKey(group_map_, group_name)); 292 CHECK(ContainsKey(group_map_, group_name));
293 293
294 Group& group = group_map_[group_name]; 294 Group& group = group_map_[group_name];
295 295
296 CHECK(group.backup_task); 296 CHECK(group.backup_task);
297 group.backup_task = NULL; 297 group.backup_task = NULL;
298 298
299 CHECK(group.backup_job); 299 CHECK(group.backup_job);
300 300
301 // If our backup job is waiting on DNS, just reset the timer. 301 // If our backup job is waiting on DNS, or if we can't create any sockets
302 // right now due to limits, just reset the timer.
302 CHECK(group.jobs.size()); 303 CHECK(group.jobs.size());
303 if ((*group.jobs.begin())->GetLoadState() == LOAD_STATE_RESOLVING_HOST) { 304 if (ReachedMaxSocketsLimit() ||
305 !group.HasAvailableSocketSlot(max_sockets_per_group_) ||
306 (*group.jobs.begin())->GetLoadState() == LOAD_STATE_RESOLVING_HOST) {
304 group.backup_job->net_log().EndEvent( 307 group.backup_job->net_log().EndEvent(
305 NetLog::TYPE_SOCKET_BACKUP_TIMER_EXTENDED); 308 NetLog::TYPE_SOCKET_BACKUP_TIMER_EXTENDED);
306 StartBackupSocketTimer(group_name); 309 StartBackupSocketTimer(group_name);
307 return; 310 return;
308 } 311 }
309 312
310 group.backup_job->net_log().AddEvent(NetLog::TYPE_SOCKET_BACKUP_CREATED); 313 group.backup_job->net_log().AddEvent(NetLog::TYPE_SOCKET_BACKUP_CREATED);
311 SIMPLE_STATS_COUNTER("socket.backup_created"); 314 SIMPLE_STATS_COUNTER("socket.backup_created");
312 int rv = group.backup_job->Connect(); 315 int rv = group.backup_job->Connect();
313 connecting_socket_count_++; 316 connecting_socket_count_++;
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 } else { 719 } else {
717 ++i; 720 ++i;
718 } 721 }
719 } 722 }
720 } 723 }
721 724
722 bool ClientSocketPoolBaseHelper::ReachedMaxSocketsLimit() const { 725 bool ClientSocketPoolBaseHelper::ReachedMaxSocketsLimit() const {
723 // Each connecting socket will eventually connect and be handed out. 726 // Each connecting socket will eventually connect and be handed out.
724 int total = handed_out_socket_count_ + connecting_socket_count_; 727 int total = handed_out_socket_count_ + connecting_socket_count_;
725 DCHECK_LE(total, max_sockets_); 728 DCHECK_LE(total, max_sockets_);
726 return total == max_sockets_; 729 if (total < max_sockets_)
730 return false;
731 LOG(WARNING) << "ReachedMaxSocketsLimit: " << total << "/" << max_sockets_;
732 return true;
727 } 733 }
728 734
729 } // namespace internal 735 } // namespace internal
730 736
731 } // namespace net 737 } // 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