Chromium Code Reviews
[email protected] (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Issue 2994003: Refactor how ClientSocketPoolBaseHelper avoids re-entrancy. (Closed)

Created:
10 years, 5 months ago by willchan no longer on Chromium
Modified:
9 years, 7 months ago
Reviewers:
Mike Belshe, eroman
CC:
chromium-reviews, cbentzel+watch_chromium.org, darin-cc_chromium.org, Paweł Hajdan Jr.
Base URL:
http://src.chromium.org/git/chromium.git
Visibility:
Public.

Description

Refactor how ClientSocketPoolBaseHelper avoids re-entrancy. Specifically, we defer asynchronous user callbacks to tasks. BUG=48861 Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=52509

Patch Set 1 #

Total comments: 14

Patch Set 2 : Address mbelshe comments. #

Patch Set 3 : Oops, missed one comment. #

Total comments: 11

Patch Set 4 : Address eroman comments. #

Total comments: 1

Patch Set 5 : Merge. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+164 lines, -134 lines) Patch
M net/http/http_network_transaction_unittest.cc View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M net/http/http_proxy_client_socket_pool.h View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M net/http/http_proxy_client_socket_pool.cc View 1 chunk +1 line, -1 line 0 comments Download
M net/socket/client_socket_handle.h View 1 2 3 4 3 chunks +3 lines, -1 line 0 comments Download
M net/socket/client_socket_handle.cc View 1 2 3 4 4 chunks +7 lines, -3 lines 0 comments Download
M net/socket/client_socket_pool.h View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M net/socket/client_socket_pool_base.h View 1 2 3 4 9 chunks +43 lines, -21 lines 0 comments Download
M net/socket/client_socket_pool_base.cc View 1 2 3 4 15 chunks +89 lines, -85 lines 0 comments Download
M net/socket/client_socket_pool_base_unittest.cc View 1 2 3 4 3 chunks +3 lines, -6 lines 0 comments Download
M net/socket/socket_test_util.h View 1 2 3 4 3 chunks +4 lines, -4 lines 0 comments Download
M net/socket/socket_test_util.cc View 1 2 3 4 3 chunks +5 lines, -4 lines 0 comments Download
M net/socket/socks_client_socket_pool.h View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M net/socket/socks_client_socket_pool.cc View 1 chunk +1 line, -1 line 0 comments Download
M net/socket/ssl_client_socket_pool.h View 1 chunk +1 line, -1 line 0 comments Download
M net/socket/ssl_client_socket_pool.cc View 1 chunk +1 line, -1 line 0 comments Download
M net/socket/tcp_client_socket_pool.h View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M net/socket/tcp_client_socket_pool.cc View 1 chunk +1 line, -1 line 0 comments Download

Messages

Total messages: 8 (0 generated)
willchan no longer on Chromium
This is just a refactor for simplicity. The nice thing about doing things this way ...
10 years, 5 months ago (2010-07-13 20:48:53 UTC) #1
Mike Belshe
lgtm; just a few nits. thanks for doing this before you go! http://codereview.chromium.org/2994003/diff/1/5 File net/socket/client_socket_handle.cc ...
10 years, 5 months ago (2010-07-13 21:28:11 UTC) #2
willchan no longer on Chromium
http://codereview.chromium.org/2994003/diff/1/5 File net/socket/client_socket_handle.cc (right): http://codereview.chromium.org/2994003/diff/1/5#newcode43 net/socket/client_socket_handle.cc:43: // If we did not get initialized yet, so ...
10 years, 5 months ago (2010-07-13 22:44:09 UTC) #3
eroman
Have you considered making Request refcounted instead of having the pending callbacks map? (i.e. post ...
10 years, 5 months ago (2010-07-13 23:41:10 UTC) #4
willchan no longer on Chromium
http://codereview.chromium.org/2994003/diff/8001/9001 File net/http/http_network_transaction_unittest.cc (right): http://codereview.chromium.org/2994003/diff/8001/9001#newcode262 net/http/http_network_transaction_unittest.cc:262: ClientSocketHandle* handle) { } On 2010/07/13 23:41:10, eroman wrote: ...
10 years, 5 months ago (2010-07-13 23:48:27 UTC) #5
eroman
http://codereview.chromium.org/2994003/diff/8001/9004 File net/socket/client_socket_handle.cc (right): http://codereview.chromium.org/2994003/diff/8001/9004#newcode37 net/socket/client_socket_handle.cc:37: socket_->NetLog().EndEvent(NetLog::TYPE_SOCKET_IN_USE, NULL); On 2010/07/13 23:48:27, willchan wrote: > On ...
10 years, 5 months ago (2010-07-14 00:02:54 UTC) #6
eroman
http://codereview.chromium.org/2994003/diff/15001/16008 File net/socket/client_socket_pool_base.h (right): http://codereview.chromium.org/2994003/diff/15001/16008#newcode421 net/socket/client_socket_pool_base.h:421: // exist in |pending_callback_map_|. We look up the callback ...
10 years, 5 months ago (2010-07-14 21:34:19 UTC) #7
willchan no longer on Chromium
10 years, 5 months ago (2010-07-15 16:56:40 UTC) #8
eroman and I talked about this offline.  The plan is to add a
ScopedRunnableMethodFactory into the CallbackResultPair, so we can revoke the
task when it gets cancelled.  I don't think I'll have time to do that today
before I go on leave.  I'll put a TODO there and land as is.

On 2010/07/14 21:34:19, eroman wrote:
> http://codereview.chromium.org/2994003/diff/15001/16008
> File net/socket/client_socket_pool_base.h (right):
> 
> http://codereview.chromium.org/2994003/diff/15001/16008#newcode421
> net/socket/client_socket_pool_base.h:421: // exist in |pending_callback_map_|.

> We look up the callback and result code
> This is very subtle.
> 
> The concern I have is in using a memory address as the key into the callback
> map. Since across cancellations, it is possible for the key
> (ClientSocketHandle*) to be freed. Hence we could allocate a new
> ClientSocketHandle that just happens to have the same memory address as the
old
> cancelled one that was just freed, and end up with mismatched expectations
> between the posted task and the pendingcallback map.
> 
> That said, the situations I considered happen to work, but I worry this won't
be
> future-proof.
> 
> For example, one ordering I considered was if you start off with a
> CallbackResultPair keyed by memory address XXX in the pending callback map.
> 
> Now say that XXX is completed. An invoke-later task is posted for XXX.
> Next, say that XXX is cancelled, so the pending callback result is removed
from
> the map. Next, a new a new ClientSocketHandle is allocated which happens to
have
> address XXX as well. We complete this new request right away, and post a
second
> invoke-callback-later task for XXX.
> 
> Now when processing the first invoke-callback-later task, we will end up
> completing the second ClientSocketHandle. I guess this ends up being safe
> though, since when we run the second invoke-callback task it will just be a
> no-op.
> 
> Still if things change this could get broken. For example if the |int result|
> were ever passed as a parameter of the posttask rather than part of the
> pending-callback-map, then this would result in a mistake.
> 
> Maybe I am just crazy, but I wanted to bring this up.
> 
> 
> 
> Otherwise, LGTM.

Powered by Google App Engine
This is Rietveld 408576698