summaryrefslogtreecommitdiffstats
path: root/base/shared_memory.h
diff options
context:
space:
mode:
Diffstat (limited to 'base/shared_memory.h')
-rw-r--r--base/shared_memory.h17
1 files changed, 15 insertions, 2 deletions
diff --git a/base/shared_memory.h b/base/shared_memory.h
index b44367a..744b348 100644
--- a/base/shared_memory.h
+++ b/base/shared_memory.h
@@ -8,6 +8,7 @@
#include "build/build_config.h"
#if defined(OS_POSIX)
+#include <sys/types.h>
#include <semaphore.h>
#include "base/file_descriptor_posix.h"
#endif
@@ -24,7 +25,10 @@ namespace base {
typedef HANDLE SharedMemoryHandle;
typedef HANDLE SharedMemoryLock;
#elif defined(OS_POSIX)
+// A SharedMemoryId is sufficient to identify a given shared memory segment on a
+// system, but insufficient to map it.
typedef FileDescriptor SharedMemoryHandle;
+typedef ino_t SharedMemoryId;
// On POSIX, the lock is implemented as a lockf() on the mapped file,
// so no additional member (or definition of SharedMemoryLock) is
// needed.
@@ -99,6 +103,14 @@ class SharedMemory {
// identifier is not portable.
SharedMemoryHandle handle() const;
+#if defined(OS_POSIX)
+ // Return a unique identifier for this shared memory segment. Inode numbers
+ // are technically only unique to a single filesystem. However, we always
+ // allocate shared memory backing files from the same directory, so will end
+ // up on the same filesystem.
+ SharedMemoryId id() const { return inode_; }
+#endif
+
// Closes the open shared memory segment.
// It is safe to call Close repeatedly.
void Close();
@@ -153,9 +165,10 @@ class SharedMemory {
std::wstring name_;
#if defined(OS_WIN)
- HANDLE mapped_file_;
+ HANDLE mapped_file_;
#elif defined(OS_POSIX)
- int mapped_file_;
+ int mapped_file_;
+ ino_t inode_;
#endif
void* memory_;
bool read_only_;