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

Unified Diff: base/directory_watcher_inotify.cc

Issue 147052: Fix a race condition in directory_watcher_inotify.cc: release lock before sig... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/directory_watcher_inotify.cc
===================================================================
--- base/directory_watcher_inotify.cc (revision 19144)
+++ base/directory_watcher_inotify.cc (working copy)
@@ -397,24 +397,32 @@
}
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;
+
+ {
+ // 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);
+ }
}
- 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;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698