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

Issue 5549001: Fix preconnect crash when we hit max socket limit. (Closed)

Created:
10 years ago by willchan no longer on Chromium
Modified:
9 years, 7 months ago
CC:
chromium-reviews, cbentzel+watch_chromium.org, darin-cc_chromium.org, Paweł Hajdan Jr.
Visibility:
Public.

Description

Fix preconnect crash when we hit max socket limit. When we hit the max socket limit, we close an idle socket in order to make space for the new preconnecting socket. It's possible for the selected socket to belong to the same connection group as the one we're preconnecting a socket for. This is obviously broken. The bug currently results in us potentially deleting the ClientSocketPoolHelper::Group associated with that connection group, so the |Group* group| local variable in RequestSocketInternal() is now invalid. Any access to that variable later on in the function results in badness. This was safe before because we would never try to close an idle socket in the connection group we're request a socket for, because the first condition in RequestSocketInternal() checks to see if we can reuse an idle socket. In the preconnect case, since we want to warm up the number of sockets in the connection group, we bypass idle sockets. The solution is to create a new function: CloseOneIdleSocketExceptInGroup(const Group*). This way we avoid this problem. I provide a return value so that the caller can tell whether or not an idle socket was closed. If it was not closed (it's possible that the connection group we're requesting a socket for is the only one with idle sockets), then the caller can tell, so it can pass up the failure so RequestSockets() knows that we've hit the max socket limit and there's no point in trying to preconnect more sockets. BUG=64940 TEST=New unittest. Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=67953

Patch Set 1 #

Total comments: 2

Patch Set 2 : Add TODO, fix lint error. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+100 lines, -4 lines) Patch
M net/base/net_error_list.h View 1 chunk +3 lines, -1 line 0 comments Download
M net/socket/client_socket_pool_base.h View 1 chunk +5 lines, -0 lines 0 comments Download
M net/socket/client_socket_pool_base.cc View 1 4 chunks +17 lines, -3 lines 0 comments Download
M net/socket/client_socket_pool_base_unittest.cc View 1 1 chunk +75 lines, -0 lines 0 comments Download

Messages

Total messages: 3 (0 generated)
willchan no longer on Chromium
mbelshe: You're primary reviewer here. vandebo: More of an FYI for you, so you can ...
10 years ago (2010-12-02 01:58:07 UTC) #1
Mike Belshe
LGTM. Why is preconnect able to boot a socket for its own group? http://codereview.chromium.org/5549001/diff/1/net/socket/client_socket_pool_base.cc File ...
10 years ago (2010-12-02 02:46:48 UTC) #2
willchan no longer on Chromium
10 years ago (2010-12-02 02:58:23 UTC) #3
On 2010/12/02 02:46:48, Mike Belshe wrote:
> LGTM.  
> 
> Why is preconnect able to boot a socket for its own group?

It was previously able to.  The new CloseOneIdleSocketExceptInGroup() function
makes it possible not to do this.  I've used this in RequestSocketInternal() to
prevent booting from its own group.

> 
>
http://codereview.chromium.org/5549001/diff/1/net/socket/client_socket_pool_b...
> File net/socket/client_socket_pool_base.cc (right):
> 
>
http://codereview.chromium.org/5549001/diff/1/net/socket/client_socket_pool_b...
> net/socket/client_socket_pool_base.cc:249: int rv =
> RequestSocketInternal(group_name, &request);
> On 2010/12/02 01:58:07, willchan wrote:
> > Should I special case ERR_PRECONNECT_MAX_SOCKET_LIMIT here so I can add a
new
> > NetLog EventParameter for TYPE_SOCKET_POOL_CONNECTING_N_SOCKETS so we can
tell
> > when preconnect is not warming up any more sockets due to the max socket
> limit? 
> > Will anyone read this?
> 
> It's up to you.  Maybe add a TODO

OK.

Powered by Google App Engine
This is Rietveld 408576698