diff options
author | dkegel@google.com <dkegel@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-06 19:59:36 +0000 |
---|---|---|
committer | dkegel@google.com <dkegel@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-06 19:59:36 +0000 |
commit | 4883a4e4209bab557f4ba40a002936acf755205f (patch) | |
tree | 8b1aef5a4e1fe01ee5d4e178838dec8e98356177 /base/file_util_posix.cc | |
parent | e2ffeae017f1c85d472e3f04e62e4cba21f6e9a8 (diff) | |
download | chromium_src-4883a4e4209bab557f4ba40a002936acf755205f.zip chromium_src-4883a4e4209bab557f4ba40a002936acf755205f.tar.gz chromium_src-4883a4e4209bab557f4ba40a002936acf755205f.tar.bz2 |
Prototype implementation of zygotes.
Limitations that need addressing still:
- Doesn't forcibly terminate children that should have exited but haven't
Enable with env var ENABLE_ZYGOTE_MANAGER=1.
BUG=11841
TEST=
start the browser, then make chrome and all .pak files unreadable; or alternately, start an installed browser, and uninstall the browser while it's running. Then create a new tab and browse to two new sites.
Here's an example script to hide and unhide the .pak files (note: do not move the directory they're in, that doesn't work):
#!/bin/sh
chmod_all() {
chmod $1 sconsbuild/Debug/chrome
for path in . locales obj/chrome/app/intermediate/repack obj/global_intermediate/* themes
do
chmod $1 sconsbuild/Debug/$path/*.pak
done
}
case $1 in
hide) chmod_all 000 ;;
show) chmod_all 755 ;;
esac
Review URL: http://codereview.chromium.org/115773
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17840 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/file_util_posix.cc')
-rw-r--r-- | base/file_util_posix.cc | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/base/file_util_posix.cc b/base/file_util_posix.cc index 5d44ca3..b9aa206 100644 --- a/base/file_util_posix.cc +++ b/base/file_util_posix.cc @@ -27,6 +27,7 @@ #include "base/logging.h" #include "base/string_util.h" #include "base/time.h" +#include "base/zygote_manager.h" namespace file_util { @@ -625,20 +626,37 @@ MemoryMappedFile::MemoryMappedFile() } bool MemoryMappedFile::MapFileToMemory(const FilePath& file_name) { - file_ = open(file_name.value().c_str(), O_RDONLY); + file_ = -1; +#if defined(OS_LINUX) + base::ZygoteManager* zm = base::ZygoteManager::Get(); + if (zm) { + file_ = zm->OpenFile(file_name.value().c_str()); + if (file_ == -1) { + LOG(INFO) << "Zygote manager can't open " << file_name.value() + << ", retrying locally"; + } + } +#endif // defined(OS_LINUX) if (file_ == -1) + file_ = open(file_name.value().c_str(), O_RDONLY); + if (file_ == -1) { + LOG(ERROR) << "Couldn't open " << file_name.value(); return false; + } struct stat file_stat; - if (fstat(file_, &file_stat) == -1) + if (fstat(file_, &file_stat) == -1) { + LOG(ERROR) << "Couldn't fstat " << file_name.value() << ", errno " << errno; return false; + } length_ = file_stat.st_size; data_ = static_cast<uint8*>( mmap(NULL, length_, PROT_READ, MAP_SHARED, file_, 0)); if (data_ == MAP_FAILED) - data_ = NULL; - return data_ != NULL; + LOG(ERROR) << "Couldn't mmap " << file_name.value() << ", errno " << errno; + + return data_ != MAP_FAILED; } void MemoryMappedFile::CloseHandles() { |