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

Unified Diff: base/shared_memory_posix.cc

Issue 21485: Bitmap transport (Closed)
Patch Set: Fix some mac crashes Created 11 years, 10 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
Index: base/shared_memory_posix.cc
diff --git a/base/shared_memory_posix.cc b/base/shared_memory_posix.cc
index e6f81c52961ce4a199fd323cf12b47fe61cd8018..c948e58f2d134231d69c09890348342ff4e0502a 100644
--- a/base/shared_memory_posix.cc
+++ b/base/shared_memory_posix.cc
@@ -7,6 +7,8 @@
#include <errno.h>
#include <fcntl.h>
#include <sys/mman.h>
+#include <sys/stat.h>
+#include <unistd.h>
#include "base/file_util.h"
#include "base/logging.h"
@@ -23,6 +25,7 @@ const char kSemaphoreSuffix[] = "-sem";
SharedMemory::SharedMemory()
: mapped_file_(-1),
+ inode_(0),
memory_(NULL),
read_only_(false),
max_size_(0) {
@@ -30,9 +33,16 @@ SharedMemory::SharedMemory()
SharedMemory::SharedMemory(SharedMemoryHandle handle, bool read_only)
: mapped_file_(handle.fd),
+ inode_(0),
memory_(NULL),
read_only_(read_only),
max_size_(0) {
+ struct stat st;
+ if (fstat(handle.fd, &st) == 0) {
+ // If fstat fails, then the file descriptor is invalid and we'll learn this
+ // fact when Map() fails.
+ inode_ = st.st_ino;
+ }
}
SharedMemory::SharedMemory(SharedMemoryHandle handle, bool read_only,
@@ -206,6 +216,12 @@ bool SharedMemory::CreateOrOpen(const std::wstring &name,
mapped_file_ = dup(fileno(fp));
DCHECK(mapped_file_ >= 0);
+
+ struct stat st;
+ if (fstat(mapped_file_, &st))
+ NOTREACHED();
+ inode_ = st.st_ino;
+
return true;
}

Powered by Google App Engine
This is Rietveld 408576698