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

Issue 6697020: Fixed shutdown concurrency issues in FilePathWatcher. (Closed)

Created:
9 years, 9 months ago by Joao da Silva
Modified:
9 years, 7 months ago
CC:
chromium-reviews, pam+watch_chromium.org, Paweł Hajdan Jr.
Visibility:
Public.

Description

Fixed shutdown concurrency issues in FilePathWatcher. BUG=None TEST=FilePathWatcherTest(browser_tests) Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=79029 (dcommit crashed, closing manually)

Patch Set 1 #

Total comments: 15

Patch Set 2 : Tested and updated after changes from 6670081 #

Total comments: 8

Patch Set 3 : Addressed comments. #

Patch Set 4 : Introduced CancelTask to simplify cleanup. #

Total comments: 4

Patch Set 5 : Small fixes. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+147 lines, -57 lines) Patch
M content/common/file_path_watcher/file_path_watcher.h View 1 2 3 4 3 chunks +39 lines, -10 lines 0 comments Download
M content/common/file_path_watcher/file_path_watcher.cc View 1 2 3 1 chunk +2 lines, -11 lines 0 comments Download
M content/common/file_path_watcher/file_path_watcher_inotify.cc View 1 2 3 4 chunks +36 lines, -12 lines 0 comments Download
M content/common/file_path_watcher/file_path_watcher_mac.cc View 1 2 3 9 chunks +39 lines, -13 lines 0 comments Download
M content/common/file_path_watcher/file_path_watcher_win.cc View 1 2 3 6 chunks +31 lines, -11 lines 0 comments Download

Messages

Total messages: 10 (0 generated)
Joao da Silva
FilePathWatcherImpl wasn't cleaning up correctly if its required thread was shut down, and in some ...
9 years, 9 months ago (2011-03-15 18:04:39 UTC) #1
Bernhard Bauer
We might want to have FileBasedPolicyLoader observe browser shutdown notifications and stop watching the policy ...
9 years, 9 months ago (2011-03-15 22:00:07 UTC) #2
Mattias Nissler (ping if slow)
First round of comments. http://codereview.chromium.org/6697020/diff/1/chrome/browser/file_path_watcher/file_path_watcher_mac.cc File chrome/browser/file_path_watcher/file_path_watcher_mac.cc (right): http://codereview.chromium.org/6697020/diff/1/chrome/browser/file_path_watcher/file_path_watcher_mac.cc#newcode125 chrome/browser/file_path_watcher/file_path_watcher_mac.cc:125: DestroyEventStream(); If I understand correctly, ...
9 years, 9 months ago (2011-03-16 09:41:14 UTC) #3
Joao da Silva
This CL has been updated after the changes introduced in http://codereview.chromium.org/6670081. The bugs still exist ...
9 years, 9 months ago (2011-03-18 16:09:17 UTC) #4
Mattias Nissler (ping if slow)
Looks like the right approach in general. However, I still don't understand why we would ...
9 years, 9 months ago (2011-03-21 16:07:45 UTC) #5
Joao da Silva
Thanks for offline discussions. Please see comments. http://codereview.chromium.org/6697020/diff/6001/content/common/file_path_watcher/file_path_watcher_inotify.cc File content/common/file_path_watcher/file_path_watcher_inotify.cc (right): http://codereview.chromium.org/6697020/diff/6001/content/common/file_path_watcher/file_path_watcher_inotify.cc#newcode397 content/common/file_path_watcher/file_path_watcher_inotify.cc:397: // executed ...
9 years, 9 months ago (2011-03-22 10:10:08 UTC) #6
Joao da Silva
Here's a revised version, using a custom Task to Cancel the FilePathWatcher::PlatformDelegate either when run ...
9 years, 9 months ago (2011-03-22 16:31:07 UTC) #7
Mattias Nissler (ping if slow)
I like this version. The only thing I'm unsure about is writing the cancelled flag ...
9 years, 9 months ago (2011-03-22 17:23:43 UTC) #8
Joao da Silva
Thanks for reviewing, see comments below. > I like this version. The only thing I'm ...
9 years, 9 months ago (2011-03-22 17:42:33 UTC) #9
Mattias Nissler (ping if slow)
9 years, 9 months ago (2011-03-22 17:48:17 UTC) #10
On 2011/03/22 17:42:33, joaodasilva wrote:
> Thanks for reviewing, see comments below.
> 
> > I like this version. The only thing I'm unsure about is writing the
cancelled
> > flag from the various Cancel() methods on potentially the wrong thread. Is
> this
> > safe w.r.t. to races on the flag?
> 
> I believe it's safe as it is. set_cancelled() is called on only 2 cases:
> 
> 1) on Cancel(), when Watch() was never called. This could be on any thread,
but
> is not a problem. There is nothing to clean up in this case, Cancel() was
called
> from ~FilePathWatcher(), and after returning from Cancel() the FilePathWatcher
> will release its reference on the FilePathWatcherImpl, which will be
destructed
> and checks the flag, all in the same thread. So this case is OK.

I was actually wondering about concurrent calls to Watch() that would race
against the Cancel(), but this cannot happen since Watch() and Cancel() must be
called on the same thread.

> 
> 2) Cancel() posts a CancelTask. In this case, the CancelTask will hold a
> reference to the FilePathWatcherImpl, preventing it from being destroyed with
> the FilePathWatcher. The CancelTask will call CancelOnMessageLoopThread() on
the
> right thread, which will call set_cancelled(). Once this is done, the task is
> also done and is deleted, releasing the reference on the Impl and
is_cancelled()
> is then called on the destructor. This is again happening on the same thread
as
> the set_cancelled() call.

Correct.

> 
> There is also one call to is_cancelled() from UpdateStream(), but this call
can
> only happen on the "cleanup" thread from case 2 above, so it's not an issue
> either.
> 
> I hope the long text is not confusing :-) Does it make sense to you?

Yes, thanks.

> 
>
http://codereview.chromium.org/6697020/diff/15001/content/common/file_path_wa...
> File content/common/file_path_watcher/file_path_watcher.h (right):
> 
>
http://codereview.chromium.org/6697020/diff/15001/content/common/file_path_wa...
> content/common/file_path_watcher/file_path_watcher.h:54: class CancelTask:
> public Task {
> On 2011/03/22 17:23:44, Mattias Nissler wrote:
> > missing space before :
> 
> Done.
> 
>
http://codereview.chromium.org/6697020/diff/15001/content/common/file_path_wa...
> content/common/file_path_watcher/file_path_watcher.h:65:
> scoped_refptr<PlatformDelegate> delegate_;
> On 2011/03/22 17:23:44, Mattias Nissler wrote:
> > DISALLOW_COPY_AND_ASSIGN
> 
> Done.

And finally: LGTM!

Powered by Google App Engine
This is Rietveld 408576698