Skip to content

Commit

Permalink
Enable shared memory handle sharing in NaCl.
Browse files Browse the repository at this point in the history
The destructor for base::SharedMemory closes its handle on destruction.
To keep a shared memory region alive after using it, we need to
duplicate the handle. This uses dup(), which is available in native
client.

BUG=


Review URL: https://chromiumcodereview.appspot.com/11817020

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@176133 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
teravest@chromium.org committed Jan 10, 2013
1 parent f884f30 commit 52d1b4e
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion base/shared_memory_nacl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,18 @@ void SharedMemory::Unlock() {
bool SharedMemory::ShareToProcessCommon(ProcessHandle process,
SharedMemoryHandle *new_handle,
bool close_self) {
return false;
const int new_fd = dup(mapped_file_);
if (new_fd < 0) {
DPLOG(ERROR) << "dup() failed.";
return false;
}

new_handle->fd = new_fd;
new_handle->auto_close = true;

if (close_self)
Close();
return true;
}

} // namespace base

0 comments on commit 52d1b4e

Please sign in to comment.