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

Unified Diff: chrome/browser/nacl_host/nacl_process_host.cc

Issue 8587055: Revert 110557 - Use nacl::CreateMemoryObject to create dynamic code shared memory object (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 1 month 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/nacl_host/nacl_process_host.cc
===================================================================
--- chrome/browser/nacl_host/nacl_process_host.cc (revision 110570)
+++ chrome/browser/nacl_host/nacl_process_host.cc (working copy)
@@ -501,18 +501,22 @@
#if defined(OS_POSIX)
// For dynamic loading support, NaCl requires a file descriptor on an
// anonymous file that can have PROT_EXEC applied to its mappings.
- // Rather than requiring an extra IPC round trip out of the sandbox, we
- // create an FD here. Note we're using nacl::CreateMemoryObject rather
- // than base::SharedMemory here, because the former has code to handle
- // the Linux cases where shm_open yields objects that do not support
- // PROT_EXEC mappings.
- nacl::Handle fd = nacl::CreateMemoryObject(1, true); // size, executable
- if (fd == nacl::kInvalidHandle) {
+ // Rather than requiring an extra IPC round trip out of the sandbox,
+ // we create an FD here.
+ base::SharedMemory memory_buffer;
+ if (!memory_buffer.CreateAnonymous(/* size= */ 1)) {
LOG(ERROR) << "Failed to allocate memory buffer";
delete this;
return;
}
- nacl::FileDescriptor memory_fd(fd, true);
+ nacl::FileDescriptor memory_fd;
+ memory_fd.fd = dup(memory_buffer.handle().fd);
+ if (memory_fd.fd < 0) {
+ LOG(ERROR) << "Failed to dup() a file descriptor";
+ delete this;
+ return;
+ }
+ memory_fd.auto_close = true;
handles_for_sel_ldr.push_back(memory_fd);
#endif
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698