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

Unified Diff: runtime/bin/directory_android.cc

Issue 11794048: Fix race condition in Directory.create. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 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 | runtime/bin/directory_linux.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/directory_android.cc
diff --git a/runtime/bin/directory_android.cc b/runtime/bin/directory_android.cc
index dbdfca77744f937bae8e721d07fd4745a72ff988..f3f471fd0e21594fddde6158711f2a0c8013f06f 100644
--- a/runtime/bin/directory_android.cc
+++ b/runtime/bin/directory_android.cc
@@ -391,7 +391,12 @@ char* Directory::Current() {
bool Directory::Create(const char* dir_name) {
// Create the directory with the permissions specified by the
// process umask.
- return (TEMP_FAILURE_RETRY(mkdir(dir_name, 0777)) == 0);
+ int result = TEMP_FAILURE_RETRY(mkdir(dir_name, 0777));
+ // If the directory already exists, treat it as a success.
+ if (result == -1 && errno == EEXISTS) {
+ return (Exists(dir_name) == EXISTS);
+ }
+ return (result == 0);
}
« no previous file with comments | « no previous file | runtime/bin/directory_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698