|
|
Created:
6 years, 2 months ago by byungwoo Modified:
6 years, 1 month ago CC:
chromium-reviews, vsevik, jam, yurys, paulirish+reviews_chromium.org, darin-cc_chromium.org, devtools-reviews_chromium.org, aandrey+blink_chromium.org, pfeldman Base URL:
https://chromium.googlesource.com/chromium/src.git@master Project:
chromium Visibility:
Public. |
Description[DevTools] Keep IP address of HttpServer as a member of DevToolsHttpHandlerImpl.
Fix the problem that loading inspector from content_shell is failing with
thread_checker_.CalledOnValidThread() failed.
At ShellDevToolsFrontend::Show(), DevToolsHttpHandlerImpl::GetFrontendURL()
is called to get the frontend url, and inside the function,
HttpServer::GetLocalAddress() is called directly which is expected to be
called on the DevToolsHandler thread only.
To prevent the DCHECK failure, this patch keeps the ip address of HttpServer
as a member of DevToolsHttpHandlerImpl instance and use it.
BUG=425423
Committed: https://crrev.com/9fd9f0a04570cefb62b18bdac864636fc7e05026
Cr-Commit-Position: refs/heads/master@{#301684}
Patch Set 1 #Patch Set 2 : Move the server_ip_address declaration next to the server_ #
Total comments: 2
Patch Set 3 : Added a lock for server_ip_address_. #
Total comments: 2
Patch Set 4 : post ip_address to UI thread. #Patch Set 5 : Remove unnecessary forward declaration. #
Total comments: 1
Patch Set 6 : clear server_ip_address_ at Teardown. #Patch Set 7 : Move server_ip_address_.reset() from Teardown to StopHandlerThread #Patch Set 8 : Move server_ip_address_.reset() to ResetHandlerThread() #
Messages
Total messages: 31 (8 generated)
bw80.lee@samsung.com changed reviewers: + dgozman@chromium.org, kaznacheev@chromium.org
bw80.lee@samsung.com changed reviewers: + pfeldman@chromium.org, vkuzkokov@chromium.org
It still has a race since the server address is assigned on one thread and is read on another. https://codereview.chromium.org/666673007/diff/20001/content/browser/devtools... File content/browser/devtools/devtools_http_handler_impl.cc (right): https://codereview.chromium.org/666673007/diff/20001/content/browser/devtools... content/browser/devtools/devtools_http_handler_impl.cc:336: if (!server_ip_address_) This is called on the UI thread. https://codereview.chromium.org/666673007/diff/20001/content/browser/devtools... content/browser/devtools/devtools_http_handler_impl.cc:800: server_ip_address_.reset(new net::IPEndPoint(ip_address)); This is called on the handler thread.
On 2014/10/21 11:32:47, pfeldman wrote: > It still has a race since the server address is assigned on one thread and is > read on another. Yes right. This fixed the DCHECK failure but still has the race as previous. So, is it better to add a mutex for server_ip_address_ to handle the race condition?
I updated the patch with adding lock for the server_ip_address_. Please take a look again :)
vkuzkokov@chromium.org changed reviewers: - kaznacheev@chromium.org
https://codereview.chromium.org/666673007/diff/40001/content/browser/devtools... File content/browser/devtools/devtools_http_handler_impl.cc (right): https://codereview.chromium.org/666673007/diff/40001/content/browser/devtools... content/browser/devtools/devtools_http_handler_impl.cc:799: base::AutoLock locked(server_ip_address_lock_); Use of locks is very limited in chromium, especially on the UI thread. The go-to way for doing this is to post IPEndPoint using BrowserThread::PostTask and read and modify server_ip_address_ only on UI.
https://codereview.chromium.org/666673007/diff/40001/content/browser/devtools... File content/browser/devtools/devtools_http_handler_impl.cc (right): https://codereview.chromium.org/666673007/diff/40001/content/browser/devtools... content/browser/devtools/devtools_http_handler_impl.cc:799: base::AutoLock locked(server_ip_address_lock_); On 2014/10/22 13:20:03, vkuzkokov wrote: > Use of locks is very limited in chromium, especially on the UI thread. > The go-to way for doing this is to post IPEndPoint using BrowserThread::PostTask > and read and modify server_ip_address_ only on UI. Thank you for the review and suggestion. I'll apply it.
Could you please take a look?
https://codereview.chromium.org/666673007/diff/80001/content/browser/devtools... File content/browser/devtools/devtools_http_handler_impl.cc (right): https://codereview.chromium.org/666673007/diff/80001/content/browser/devtools... content/browser/devtools/devtools_http_handler_impl.cc:830: thread_->message_loop()->PostTask( It seems like you could clear server_ip_address_ at this point instead of posting back to UI from Teardown.
On 2014/10/27 09:51:44, vkuzkokov wrote: > https://codereview.chromium.org/666673007/diff/80001/content/browser/devtools... > content/browser/devtools/devtools_http_handler_impl.cc:830: > thread_->message_loop()->PostTask( > It seems like you could clear server_ip_address_ at this point instead of > posting back to UI from Teardown. Yes, right. Thank you for the review. I applied and uploaded new patch set. :)
On 2014/10/27 10:51:55, byungwoo wrote: > On 2014/10/27 09:51:44, vkuzkokov wrote: > > > https://codereview.chromium.org/666673007/diff/80001/content/browser/devtools... > > content/browser/devtools/devtools_http_handler_impl.cc:830: > > thread_->message_loop()->PostTask( > > It seems like you could clear server_ip_address_ at this point instead of > > posting back to UI from Teardown. > Yes, right. Thank you for the review. > I applied and uploaded new patch set. :) I meant clearing it in StopHandlerThread before (or after - that shouldn't matter) posting Teardown. Teardown itself is called on handler thread and changing server_ip_address_ in it will cause race condition. Also, a nit: instead of .reset(NULL) just .reset() is used.
On 2014/10/27 11:31:58, vkuzkokov wrote: > On 2014/10/27 10:51:55, byungwoo wrote: > > On 2014/10/27 09:51:44, vkuzkokov wrote: > > > > > > https://codereview.chromium.org/666673007/diff/80001/content/browser/devtools... > > > content/browser/devtools/devtools_http_handler_impl.cc:830: > > > thread_->message_loop()->PostTask( > > > It seems like you could clear server_ip_address_ at this point instead of > > > posting back to UI from Teardown. > > Yes, right. Thank you for the review. > > I applied and uploaded new patch set. :) > > I meant clearing it in StopHandlerThread before (or after - that shouldn't > matter) posting Teardown. > Teardown itself is called on handler thread and changing server_ip_address_ in > it will cause race condition. > > Also, a nit: instead of .reset(NULL) just .reset() is used. Ok. I thought that you told it would be ok to clear it in TearDown because it is called during the cleanup sequence. Sorry for my misunderstanding. As you told, accessing the ip address member in handler thread can cause race condition as pointed previously. I will apply it again. (And I'll fix the server_.reset(NULL) to .reset() as you pointed)
lgtm
lgtm
On 2014/10/27 13:09:58, vkuzkokov wrote: > lgtm My bad: StopHandlerThread doesn't run on UI - it runs on FILE as is written in the comment right above it (Duh). So server_ip_address_ should be cleared even earlier: from Stop and StopWithoutRelease.
On 2014/10/27 13:52:00, vkuzkokov wrote: > So server_ip_address_ should be cleared even earlier: from Stop and > StopWithoutRelease. How about clearing it at ResetHandlerThread() ? ResetHandlerThread() will be called on the UI thread after StopHandlerThread() is finished on the FILE thread.
On 2014/10/27 15:31:32, byungwoo wrote: > On 2014/10/27 13:52:00, vkuzkokov wrote: > > So server_ip_address_ should be cleared even earlier: from Stop and > > StopWithoutRelease. > > How about clearing it at ResetHandlerThread() ? > ResetHandlerThread() will be called on the UI thread after StopHandlerThread() > is finished on the FILE thread. That should work just as well.
On 2014/10/27 15:36:27, vkuzkokov wrote: > On 2014/10/27 15:31:32, byungwoo wrote: > > On 2014/10/27 13:52:00, vkuzkokov wrote: > > > So server_ip_address_ should be cleared even earlier: from Stop and > > > StopWithoutRelease. > > > > How about clearing it at ResetHandlerThread() ? > > ResetHandlerThread() will be called on the UI thread after StopHandlerThread() > > is finished on the FILE thread. > > That should work just as well. Applied and uploaded again. Thanks :)
On 2014/10/27 15:53:01, byungwoo wrote: > On 2014/10/27 15:36:27, vkuzkokov wrote: > > On 2014/10/27 15:31:32, byungwoo wrote: > > > On 2014/10/27 13:52:00, vkuzkokov wrote: > > > > So server_ip_address_ should be cleared even earlier: from Stop and > > > > StopWithoutRelease. > > > > > > How about clearing it at ResetHandlerThread() ? > > > ResetHandlerThread() will be called on the UI thread after > StopHandlerThread() > > > is finished on the FILE thread. > > > > That should work just as well. > > Applied and uploaded again. Thanks :) lgtm
The CQ bit was checked by vkuzkokov@chromium.org
The CQ bit was unchecked by vkuzkokov@chromium.org
If you are ready to commit this feel free to do so.
The CQ bit was checked by bw80.lee@samsung.com
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/666673007/140001
The CQ bit was unchecked by commit-bot@chromium.org
Try jobs failed on following builders: linux_chromium_gn_dbg on tryserver.chromium.linux (http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...) linux_chromium_gn_rel on tryserver.chromium.linux (http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_...)
The CQ bit was checked by vkuzkokov@chromium.org
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/666673007/140001
Message was sent while issue was closed.
Committed patchset #8 (id:140001)
Message was sent while issue was closed.
Patchset 8 (id:??) landed as https://crrev.com/9fd9f0a04570cefb62b18bdac864636fc7e05026 Cr-Commit-Position: refs/heads/master@{#301684} |