aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjorlow@chromium.org <jorlow@chromium.org@62dab493-f737-651d-591e-8d6aee1b9529>2011-03-22 19:07:54 +0000
committerjorlow@chromium.org <jorlow@chromium.org@62dab493-f737-651d-591e-8d6aee1b9529>2011-03-22 19:07:54 +0000
commitdbbc21b601732980df7a6e877e75a31e9ec1e42b (patch)
tree0260f82fcb9fb3fbde7e106157c878754f70680b
parentb887f640bae906abfb77fdf418be63350b4c5e1f (diff)
downloadsrc-dbbc21b601732980df7a6e877e75a31e9ec1e42b.tar.gz
Make GetTestDirectory threadsafe within Chromium and make it work on Windows.
git-svn-id: http://leveldb.googlecode.com/svn/trunk@13 62dab493-f737-651d-591e-8d6aee1b9529
-rw-r--r--util/env_chromium.cc9
1 files changed, 8 insertions, 1 deletions
diff --git a/util/env_chromium.cc b/util/env_chromium.cc
index 49666f6..fb700ae 100644
--- a/util/env_chromium.cc
+++ b/util/env_chromium.cc
@@ -60,6 +60,9 @@ namespace {
class Thread;
+static const ::FilePath::CharType kLevelDBTestDirectoryPrefix[]
+ = FILE_PATH_LITERAL("leveldb-test-");
+
::FilePath CreateFilePath(const std::string& file_path) {
#if defined(OS_WIN)
return FilePath(UTF8ToUTF16(file_path));
@@ -391,12 +394,16 @@ class ChromiumEnv : public Env {
}
virtual Status GetTestDirectory(std::string* path) {
+ mu_.Acquire();
if (test_directory_.empty()) {
- if (!::file_util::CreateNewTempDirectory("leveldb-", &test_directory_)) {
+ if (!::file_util::CreateNewTempDirectory(kLevelDBTestDirectoryPrefix,
+ &test_directory_)) {
+ mu_.Release();
return Status::IOError("Could not create temp directory.");
}
}
*path = FilePathToString(test_directory_);
+ mu_.Release();
return Status::OK();
}