summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authorphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-24 18:43:44 +0000
committerphajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-24 18:43:44 +0000
commit7a2cbecd237d99b73e8c3a4b776cee054b2381e7 (patch)
tree679b74354a402cdb15e7e068bb7d2ca76c7e72a0 /base
parent83aeb19dc36f13df65979d3c203d83ab82357319 (diff)
downloadchromium_src-7a2cbecd237d99b73e8c3a4b776cee054b2381e7.zip
chromium_src-7a2cbecd237d99b73e8c3a4b776cee054b2381e7.tar.gz
chromium_src-7a2cbecd237d99b73e8c3a4b776cee054b2381e7.tar.bz2
Fix a race condition in directory_watcher_inotify.cc: release lock before signaling the event dtor waits on.
http://crbug.com/15055 Review URL: http://codereview.chromium.org/147052 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19151 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/directory_watcher_inotify.cc40
1 files changed, 24 insertions, 16 deletions
diff --git a/base/directory_watcher_inotify.cc b/base/directory_watcher_inotify.cc
index ee42127..9847569 100644
--- a/base/directory_watcher_inotify.cc
+++ b/base/directory_watcher_inotify.cc
@@ -397,24 +397,32 @@ bool DirectoryWatcherImpl::OnEnumeratedSubtree(const FilePathSet& subtree) {
}
bool success = true;
- AutoLock auto_lock(lock_);
- for (FilePathSet::iterator subdirectory = subtree.begin();
- subdirectory != subtree.end();
- ++subdirectory) {
- ino_t inode;
- if (!file_util::GetInode(*subdirectory, &inode)) {
- success = false;
- continue;
- }
- if (IsInodeWatched(inode))
- continue;
- InotifyReader::Watch watch =
- Singleton<InotifyReader>::get()->AddWatch(*subdirectory, this);
- if (watch != InotifyReader::kInvalidWatch) {
- watches_.insert(watch);
- inodes_watched_.insert(inode);
+
+ {
+ // Limit the scope of auto_lock so it releases lock_ before we signal
+ // recursive_setup_finished_. Our dtor waits on recursive_setup_finished_
+ // and could otherwise destroy the lock before we release it.
+ AutoLock auto_lock(lock_);
+
+ for (FilePathSet::iterator subdirectory = subtree.begin();
+ subdirectory != subtree.end();
+ ++subdirectory) {
+ ino_t inode;
+ if (!file_util::GetInode(*subdirectory, &inode)) {
+ success = false;
+ continue;
+ }
+ if (IsInodeWatched(inode))
+ continue;
+ InotifyReader::Watch watch =
+ Singleton<InotifyReader>::get()->AddWatch(*subdirectory, this);
+ if (watch != InotifyReader::kInvalidWatch) {
+ watches_.insert(watch);
+ inodes_watched_.insert(inode);
+ }
}
}
+
recursive_setup_finished_.Signal();
return success;
}