diff options
Diffstat (limited to 'chromium/base/memory')
-rw-r--r-- | chromium/base/memory/shared_memory.h | 9 | ||||
-rw-r--r-- | chromium/base/memory/shared_memory_fuchsia.cc | 3 | ||||
-rw-r--r-- | chromium/base/memory/shared_memory_helper.cc | 7 | ||||
-rw-r--r-- | chromium/base/memory/shared_memory_mac.cc | 1 | ||||
-rw-r--r-- | chromium/base/memory/shared_memory_nacl.cc | 3 | ||||
-rw-r--r-- | chromium/base/memory/shared_memory_posix.cc | 3 | ||||
-rw-r--r-- | chromium/base/memory/shared_memory_win.cc | 3 |
7 files changed, 12 insertions, 17 deletions
diff --git a/chromium/base/memory/shared_memory.h b/chromium/base/memory/shared_memory.h index 2ab7870f4f0..2eb9ee29223 100644 --- a/chromium/base/memory/shared_memory.h +++ b/chromium/base/memory/shared_memory.h @@ -189,11 +189,10 @@ class BASE_EXPORT SharedMemory { // identifier is not portable. SharedMemoryHandle handle() const; - // Returns the underlying OS handle for this segment. The caller also gets - // ownership of the handle. This is logically equivalent to: - // SharedMemoryHandle dup = DuplicateHandle(handle()); - // Close(); - // return dup; + // Returns the underlying OS handle for this segment. The caller takes + // ownership of the handle and memory is unmapped. This is equivalent to + // duplicating the handle and then calling Unmap() and Close() on this object, + // without the overhead of duplicating the handle. SharedMemoryHandle TakeHandle(); // Closes the open shared memory segment. The memory will remain mapped if diff --git a/chromium/base/memory/shared_memory_fuchsia.cc b/chromium/base/memory/shared_memory_fuchsia.cc index 15211d9fbac..4036bf6f2e1 100644 --- a/chromium/base/memory/shared_memory_fuchsia.cc +++ b/chromium/base/memory/shared_memory_fuchsia.cc @@ -138,9 +138,8 @@ SharedMemoryHandle SharedMemory::handle() const { SharedMemoryHandle SharedMemory::TakeHandle() { SharedMemoryHandle handle(shm_); handle.SetOwnershipPassesToIPC(true); + Unmap(); shm_ = SharedMemoryHandle(); - memory_ = nullptr; - mapped_size_ = 0; return handle; } diff --git a/chromium/base/memory/shared_memory_helper.cc b/chromium/base/memory/shared_memory_helper.cc index 91893d335e2..f98b734fb7f 100644 --- a/chromium/base/memory/shared_memory_helper.cc +++ b/chromium/base/memory/shared_memory_helper.cc @@ -41,13 +41,12 @@ bool CreateAnonymousSharedMemory(const SharedMemoryCreateOptions& options, // A: Because they're limited to 4mb on OS X. FFFFFFFUUUUUUUUUUU FilePath directory; ScopedPathUnlinker path_unlinker; - ScopedFILE fp; if (!GetShmemTempDir(options.executable, &directory)) return false; - fp.reset(base::CreateAndOpenTemporaryFileInDir(directory, path)); + fd->reset(base::CreateAndOpenFdForTemporaryFileInDir(directory, path)); - if (!fp) + if (!fd->is_valid()) return false; // Deleting the file prevents anyone else from mapping it in (making it @@ -60,10 +59,10 @@ bool CreateAnonymousSharedMemory(const SharedMemoryCreateOptions& options, readonly_fd->reset(HANDLE_EINTR(open(path->value().c_str(), O_RDONLY))); if (!readonly_fd->is_valid()) { DPLOG(ERROR) << "open(\"" << path->value() << "\", O_RDONLY) failed"; + fd->reset(); return false; } } - fd->reset(fileno(fp.release())); return true; } diff --git a/chromium/base/memory/shared_memory_mac.cc b/chromium/base/memory/shared_memory_mac.cc index e2735f7f963..0a233e5fb02 100644 --- a/chromium/base/memory/shared_memory_mac.cc +++ b/chromium/base/memory/shared_memory_mac.cc @@ -229,6 +229,7 @@ SharedMemoryHandle SharedMemory::handle() const { SharedMemoryHandle SharedMemory::TakeHandle() { SharedMemoryHandle dup = DuplicateHandle(handle()); + Unmap(); Close(); return dup; } diff --git a/chromium/base/memory/shared_memory_nacl.cc b/chromium/base/memory/shared_memory_nacl.cc index 442c0360f29..4bcbb547d38 100644 --- a/chromium/base/memory/shared_memory_nacl.cc +++ b/chromium/base/memory/shared_memory_nacl.cc @@ -117,9 +117,8 @@ SharedMemoryHandle SharedMemory::handle() const { SharedMemoryHandle SharedMemory::TakeHandle() { SharedMemoryHandle handle_copy = shm_; handle_copy.SetOwnershipPassesToIPC(true); + Unmap(); shm_ = SharedMemoryHandle(); - memory_ = nullptr; - mapped_size_ = 0; return handle_copy; } diff --git a/chromium/base/memory/shared_memory_posix.cc b/chromium/base/memory/shared_memory_posix.cc index f9d71f4739c..d3163e5a640 100644 --- a/chromium/base/memory/shared_memory_posix.cc +++ b/chromium/base/memory/shared_memory_posix.cc @@ -336,9 +336,8 @@ SharedMemoryHandle SharedMemory::handle() const { SharedMemoryHandle SharedMemory::TakeHandle() { SharedMemoryHandle handle_copy = shm_; handle_copy.SetOwnershipPassesToIPC(true); + Unmap(); shm_ = SharedMemoryHandle(); - memory_ = nullptr; - mapped_size_ = 0; return handle_copy; } diff --git a/chromium/base/memory/shared_memory_win.cc b/chromium/base/memory/shared_memory_win.cc index 5540004730b..cf06dd39c76 100644 --- a/chromium/base/memory/shared_memory_win.cc +++ b/chromium/base/memory/shared_memory_win.cc @@ -373,9 +373,8 @@ SharedMemoryHandle SharedMemory::handle() const { SharedMemoryHandle SharedMemory::TakeHandle() { SharedMemoryHandle handle(shm_); handle.SetOwnershipPassesToIPC(true); + Unmap(); shm_ = SharedMemoryHandle(); - memory_ = nullptr; - mapped_size_ = 0; return handle; } |