summaryrefslogtreecommitdiffstats
path: root/base/shared_memory_posix.cc
diff options
context:
space:
mode:
authorevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-29 20:43:20 +0000
committerevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-29 20:43:20 +0000
commit2e9399db87c6bddacc4a3eab43c6ea7383c0c524 (patch)
tree05a4780aa3a8f30d2ee52de38edd3397174deee5 /base/shared_memory_posix.cc
parentb6413b49b4a1bf216bbc70cc330e905c42db5c5b (diff)
downloadchromium_src-2e9399db87c6bddacc4a3eab43c6ea7383c0c524.zip
chromium_src-2e9399db87c6bddacc4a3eab43c6ea7383c0c524.tar.gz
chromium_src-2e9399db87c6bddacc4a3eab43c6ea7383c0c524.tar.bz2
shared_memory: improve error messages on failure.
Be careful to leave errno untouched if the file open fails, so that the latter logging statements that print errno will print the right message. Also format the logging text such that the perror-like output (appending text like ": Permission denied") makes more sense. Previously we'd end up printing text like Try [...] to fix.: Permission denied BUG=57305 TEST=shared_memory_unittest should still pass Review URL: http://codereview.chromium.org/3517003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@60986 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/shared_memory_posix.cc')
-rw-r--r--base/shared_memory_posix.cc15
1 files changed, 11 insertions, 4 deletions
diff --git a/base/shared_memory_posix.cc b/base/shared_memory_posix.cc
index 32b3dae7..7283cbd 100644
--- a/base/shared_memory_posix.cc
+++ b/base/shared_memory_posix.cc
@@ -161,7 +161,8 @@ bool SharedMemory::CreateOrOpen(const std::string& name,
// Deleting the file prevents anyone else from mapping it in
// (making it private), and prevents the need for cleanup (once
// the last fd is closed, it is truly freed).
- file_util::Delete(path, false);
+ if (fp)
+ file_util::Delete(path, false);
} else {
if (!FilePathForMemoryName(name, &path))
return false;
@@ -189,9 +190,15 @@ bool SharedMemory::CreateOrOpen(const std::string& name,
if (fp == NULL) {
if (posix_flags & O_CREAT) {
#if !defined(OS_MACOSX)
- PLOG(FATAL) << "Creating shared memory in " << path.value() << " failed. "
- << "This is frequently caused by incorrect permissions on "
- << "/dev/shm. Try 'sudo chmod 777 /dev/shm' to fix.";
+ PLOG(ERROR) << "Creating shared memory in " << path.value() << " failed";
+ FilePath dir = path.DirName();
+ if (access(dir.value().c_str(), W_OK | X_OK) < 0) {
+ PLOG(ERROR) << "Unable to access(W_OK|X_OK) " << dir.value();
+ if (dir.value() == "/dev/shm") {
+ LOG(FATAL) << "This is frequently caused by incorrect permissions on "
+ << "/dev/shm. Try 'sudo chmod 777 /dev/shm' to fix.";
+ }
+ }
#else
PLOG(ERROR) << "Creating shared memory in " << path.value() << " failed";
#endif