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

Side by Side Diff: components/nacl/zygote/nacl_fork_delegate_linux.cc

Issue 22911027: Pass StatsTable shared memory via global descriptors on Posix rather than using named shared memory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/nacl/zygote/nacl_fork_delegate_linux.h" 5 #include "components/nacl/zygote/nacl_fork_delegate_linux.h"
6 6
7 #include <signal.h> 7 #include <signal.h>
8 #include <stdlib.h> 8 #include <stdlib.h>
9 #include <sys/resource.h> 9 #include <sys/resource.h>
10 #include <sys/socket.h> 10 #include <sys/socket.h>
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 } // namespace. 103 } // namespace.
104 104
105 NaClForkDelegate::NaClForkDelegate() 105 NaClForkDelegate::NaClForkDelegate()
106 : status_(kNaClHelperUnused), 106 : status_(kNaClHelperUnused),
107 fd_(-1) {} 107 fd_(-1) {}
108 108
109 void NaClForkDelegate::Init(const int sandboxdesc) { 109 void NaClForkDelegate::Init(const int sandboxdesc) {
110 VLOG(1) << "NaClForkDelegate::Init()"; 110 VLOG(1) << "NaClForkDelegate::Init()";
111 int fds[2]; 111 int fds[2];
112 112
113 // Confirm a hard-wired assumption.
114 // The NaCl constant is from chrome/nacl/nacl_linux_helper.h
115 DCHECK(kNaClSandboxDescriptor == sandboxdesc);
116
117 CHECK(socketpair(PF_UNIX, SOCK_SEQPACKET, 0, fds) == 0); 113 CHECK(socketpair(PF_UNIX, SOCK_SEQPACKET, 0, fds) == 0);
118 base::FileHandleMappingVector fds_to_map; 114 base::FileHandleMappingVector fds_to_map;
119 fds_to_map.push_back(std::make_pair(fds[1], kNaClZygoteDescriptor)); 115 fds_to_map.push_back(std::make_pair(fds[1], kNaClZygoteDescriptor));
120 fds_to_map.push_back(std::make_pair(sandboxdesc, kNaClSandboxDescriptor)); 116 fds_to_map.push_back(std::make_pair(sandboxdesc, kNaClSandboxDescriptor));
121 117
122 // Using nacl_helper_bootstrap is not necessary on x86-64 because 118 // Using nacl_helper_bootstrap is not necessary on x86-64 because
123 // NaCl's x86-64 sandbox is not zero-address-based. Starting 119 // NaCl's x86-64 sandbox is not zero-address-based. Starting
124 // nacl_helper through nacl_helper_bootstrap works on x86-64, but it 120 // nacl_helper through nacl_helper_bootstrap works on x86-64, but it
125 // leaves nacl_helper_bootstrap mapped at a fixed address at the 121 // leaves nacl_helper_bootstrap mapped at a fixed address at the
126 // bottom of the address space, which is undesirable because it 122 // bottom of the address space, which is undesirable because it
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 if (process_type != switches::kNaClLoaderProcess) 246 if (process_type != switches::kNaClLoaderProcess)
251 return false; 247 return false;
252 *uma_name = "NaCl.Client.Helper.StateOnFork"; 248 *uma_name = "NaCl.Client.Helper.StateOnFork";
253 *uma_sample = status_; 249 *uma_sample = status_;
254 *uma_boundary_value = kNaClHelperStatusBoundary; 250 *uma_boundary_value = kNaClHelperStatusBoundary;
255 return status_ == kNaClHelperSuccess; 251 return status_ == kNaClHelperSuccess;
256 } 252 }
257 253
258 pid_t NaClForkDelegate::Fork(const std::vector<int>& fds) { 254 pid_t NaClForkDelegate::Fork(const std::vector<int>& fds) {
259 VLOG(1) << "NaClForkDelegate::Fork"; 255 VLOG(1) << "NaClForkDelegate::Fork";
260 256 DCHECK(fds.size() == kNaClParentFDIndex(fds.size()) + 1);
261 DCHECK(fds.size() == kNaClParentFDIndex + 1);
262 257
263 // First, send a remote fork request. 258 // First, send a remote fork request.
264 Pickle write_pickle; 259 Pickle write_pickle;
265 write_pickle.WriteInt(kNaClForkRequest); 260 write_pickle.WriteInt(kNaClForkRequest);
266 261
267 char reply_buf[kNaClMaxIPCMessageLength]; 262 char reply_buf[kNaClMaxIPCMessageLength];
268 ssize_t reply_size = 0; 263 ssize_t reply_size = 0;
269 bool got_reply = 264 bool got_reply =
270 SendIPCRequestAndReadReply(fd_, fds, write_pickle, 265 SendIPCRequestAndReadReply(fd_, fds, write_pickle,
271 reply_buf, sizeof(reply_buf), &reply_size); 266 reply_buf, sizeof(reply_buf), &reply_size);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 int remote_exit_code; 327 int remote_exit_code;
333 if (!iter.ReadInt(&remote_exit_code)) { 328 if (!iter.ReadInt(&remote_exit_code)) {
334 LOG(ERROR) << "GetTerminationStatus: pickle failed"; 329 LOG(ERROR) << "GetTerminationStatus: pickle failed";
335 return false; 330 return false;
336 } 331 }
337 332
338 *status = static_cast<base::TerminationStatus>(termination_status); 333 *status = static_cast<base::TerminationStatus>(termination_status);
339 *exit_code = remote_exit_code; 334 *exit_code = remote_exit_code;
340 return true; 335 return true;
341 } 336 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698