DescriptionFix 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. #
Messages
Total messages: 3 (0 generated)
|