Commit b53e1ee6 authored by Risan's avatar Risan Committed by Commit Bot

Do not recreate rm watcher if already exists

ChromeOS apparently might send 2 mount events for the same path without
unmount event in between. Apparently this cause trouble in the map
assignment:
map[x] = CreateWatcher(x)
Because there, the operation order is:
1. A new watcher is created
2. The old watcher is removed
And the old watcher is associated with the same underlying
filesystem inotify object with the newly created watcher, causing
problem.

Therefore, the assignment to the map entry should only happen when
there were no old entry.

This should solve the crash that happen only when 2 mount events for the
same path happens without unmount event in between. When there is no
such repeated mount events, this CL is not needed, which explain the
random occurrence of the crash that is fixed by this CL.

BUG=b:169910596
TEST=Login multiple times and observe no crash.

Change-Id: Ibfc2ae15a367aa3ef4b2544fcd4ad570d0ee977f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2451930
Commit-Queue: Risan <risan@chromium.org>
Reviewed-by: default avatarRyo Hashimoto <hashimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#814561}
parent be71a617
......@@ -437,6 +437,14 @@ void ArcFileSystemWatcherService::StartWatchingRemovableMedia(
base::OnceClosure callback) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
// Make sure that there is no removable media entry. Otherwise, the
// map assignment will remove the entry after a new entry is
// created, possibly causing crash if there is 2 mount events without
// unmounting events in between.
if (removable_media_watchers_.count(fs_uuid)) {
return;
}
// Make sure the callback is triggered after the file system is attached in
// file_task_runner.
base::FilePath android_path =
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment