diff options
author | Brian Carlstrom <bdc@google.com> | 2013-08-12 17:04:14 -0700 |
---|---|---|
committer | Brian Carlstrom <bdc@google.com> | 2013-08-15 10:33:53 -0700 |
commit | 7571e8b761ebc2c923525e12ea9fcf07e62cb33e (patch) | |
tree | 5d90ecf4d0ba1a72b040a376f227df1ba9278889 /compiler | |
parent | 2e250c826b3c405d675017efe79e5db3651c9ee6 (diff) | |
download | android_art-7571e8b761ebc2c923525e12ea9fcf07e62cb33e.tar.gz android_art-7571e8b761ebc2c923525e12ea9fcf07e62cb33e.tar.bz2 android_art-7571e8b761ebc2c923525e12ea9fcf07e62cb33e.zip |
Add flock(2)ing on dex-cache files to prevent races
Bug: 9071417
Change-Id: I1ee9ff281867f90fba7a8ed8bbf06b33ac29d511
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/elf_writer_test.cc | 2 | ||||
-rw-r--r-- | compiler/image_writer.cc | 4 | ||||
-rw-r--r-- | compiler/llvm/llvm_compilation_unit.cc | 4 | ||||
-rw-r--r-- | compiler/sea_ir/debug/dot_gen.h | 2 |
4 files changed, 6 insertions, 6 deletions
diff --git a/compiler/elf_writer_test.cc b/compiler/elf_writer_test.cc index e48806ecc4..ffe1f72926 100644 --- a/compiler/elf_writer_test.cc +++ b/compiler/elf_writer_test.cc @@ -62,7 +62,7 @@ TEST_F(ElfWriterTest, dlsym) { ASSERT_EQ(0, dlclose(dl_oat_so)); - UniquePtr<File> file(OS::OpenFile(elf_filename.c_str(), false)); + UniquePtr<File> file(OS::OpenFileForReading(elf_filename.c_str())); ASSERT_TRUE(file.get() != NULL); { UniquePtr<ElfFile> ef(ElfFile::Open(file.get(), false, false)); diff --git a/compiler/image_writer.cc b/compiler/image_writer.cc index a40e3fc149..4e9ae54d8e 100644 --- a/compiler/image_writer.cc +++ b/compiler/image_writer.cc @@ -79,7 +79,7 @@ bool ImageWriter::Write(const std::string& image_filename, dex_caches_.insert(dex_cache); } - UniquePtr<File> oat_file(OS::OpenFile(oat_filename.c_str(), true, false)); + UniquePtr<File> oat_file(OS::OpenFileReadWrite(oat_filename.c_str())); if (oat_file.get() == NULL) { LOG(ERROR) << "Failed to open oat file " << oat_filename << " for " << oat_location; return false; @@ -145,7 +145,7 @@ bool ImageWriter::Write(const std::string& image_filename, PatchOatCodeAndMethods(); Thread::Current()->TransitionFromRunnableToSuspended(kNative); - UniquePtr<File> image_file(OS::OpenFile(image_filename.c_str(), true)); + UniquePtr<File> image_file(OS::CreateEmptyFile(image_filename.c_str())); if (image_file.get() == NULL) { LOG(ERROR) << "Failed to open image file " << image_filename; return false; diff --git a/compiler/llvm/llvm_compilation_unit.cc b/compiler/llvm/llvm_compilation_unit.cc index 7542b841a1..139100bee9 100644 --- a/compiler/llvm/llvm_compilation_unit.cc +++ b/compiler/llvm/llvm_compilation_unit.cc @@ -155,7 +155,7 @@ void LlvmCompilationUnit::DumpBitcodeToFile() { std::string bitcode; DumpBitcodeToString(bitcode); std::string filename(StringPrintf("%s/Art%u.bc", DumpDirectory().c_str(), cunit_id_)); - UniquePtr<File> output(OS::OpenFile(filename.c_str(), true)); + UniquePtr<File> output(OS::CreateEmptyFile(filename.c_str())); output->WriteFully(bitcode.data(), bitcode.size()); LOG(INFO) << ".bc file written successfully: " << filename; } @@ -182,7 +182,7 @@ bool LlvmCompilationUnit::Materialize() { if (kDumpELF) { // Dump the ELF image for debugging std::string filename(StringPrintf("%s/Art%u.o", DumpDirectory().c_str(), cunit_id_)); - UniquePtr<File> output(OS::OpenFile(filename.c_str(), true)); + UniquePtr<File> output(OS::CreateEmptyFile(filename.c_str())); output->WriteFully(elf_object_.data(), elf_object_.size()); LOG(INFO) << ".o file written successfully: " << filename; } diff --git a/compiler/sea_ir/debug/dot_gen.h b/compiler/sea_ir/debug/dot_gen.h index 675d83d515..5270582c16 100644 --- a/compiler/sea_ir/debug/dot_gen.h +++ b/compiler/sea_ir/debug/dot_gen.h @@ -103,7 +103,7 @@ class DotConversion { LOG(INFO) << "Starting to write SEA string to file."; DotGenerationVisitor dgv = DotGenerationVisitor(&options_, types); graph->Accept(&dgv); - art::File* file = art::OS::OpenFile(filename.c_str(), true, true); + art::File* file = art::OS::OpenFile(filename.c_str(), O_RDWR | O_CREAT | O_TRUNC); art::FileOutputStream fos(file); std::string graph_as_string = dgv.GetResult(); graph_as_string += "}"; |