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

Side by Side Diff: chrome/nacl/nacl_helper_linux.cc

Issue 10695077: Better error reporting in nacl helper. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // A mini-zygote specifically for Native Client. 5 // A mini-zygote specifically for Native Client.
6 6
7 #include "chrome/common/nacl_helper_linux.h" 7 #include "chrome/common/nacl_helper_linux.h"
8 8
9 #include <errno.h> 9 #include <errno.h>
10 #include <link.h> 10 #include <link.h>
11 #include <stdio.h> 11 #include <stdio.h>
12 #include <stdlib.h> 12 #include <stdlib.h>
13 #include <sys/socket.h> 13 #include <sys/socket.h>
14 #include <sys/types.h> 14 #include <sys/types.h>
15 15
16 #include <string> 16 #include <string>
17 #include <vector> 17 #include <vector>
18 18
19 #include "base/at_exit.h" 19 #include "base/at_exit.h"
20 #include "base/command_line.h" 20 #include "base/command_line.h"
21 #include "base/eintr_wrapper.h" 21 #include "base/eintr_wrapper.h"
22 #include "base/global_descriptors_posix.h" 22 #include "base/global_descriptors_posix.h"
23 #include "base/json/string_escape.h"
23 #include "base/logging.h" 24 #include "base/logging.h"
24 #include "base/message_loop.h" 25 #include "base/message_loop.h"
25 #include "base/posix/unix_domain_socket.h" 26 #include "base/posix/unix_domain_socket.h"
26 #include "base/rand_util.h" 27 #include "base/rand_util.h"
27 #include "chrome/nacl/nacl_listener.h" 28 #include "chrome/nacl/nacl_listener.h"
28 #include "crypto/nss_util.h" 29 #include "crypto/nss_util.h"
29 #include "ipc/ipc_descriptors.h" 30 #include "ipc/ipc_descriptors.h"
30 #include "ipc/ipc_switches.h" 31 #include "ipc/ipc_switches.h"
31 32
32 namespace { 33 namespace {
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 while (true) { 217 while (true) {
217 int badpid = -1; 218 int badpid = -1;
218 std::vector<int> fds; 219 std::vector<int> fds;
219 static const unsigned kMaxMessageLength = 2048; 220 static const unsigned kMaxMessageLength = 2048;
220 char buf[kMaxMessageLength]; 221 char buf[kMaxMessageLength];
221 const ssize_t msglen = UnixDomainSocket::RecvMsg(kNaClZygoteDescriptor, 222 const ssize_t msglen = UnixDomainSocket::RecvMsg(kNaClZygoteDescriptor,
222 &buf, sizeof(buf), &fds); 223 &buf, sizeof(buf), &fds);
223 if (msglen == 0 || (msglen == -1 && errno == ECONNRESET)) { 224 if (msglen == 0 || (msglen == -1 && errno == ECONNRESET)) {
224 // EOF from the browser. Goodbye! 225 // EOF from the browser. Goodbye!
225 _exit(0); 226 _exit(0);
226 } 227 } else if (msglen < 0) {
227 if (msglen == sizeof(kNaClForkRequest) - 1 && 228 LOG(ERROR) << "nacl_helper: receive from zygote failed, errno = "
228 memcmp(buf, kNaClForkRequest, msglen) == 0) { 229 << errno;
230 } else if (msglen == sizeof(kNaClForkRequest) - 1 &&
231 memcmp(buf, kNaClForkRequest, msglen) == 0) {
229 if (kNaClParentFDIndex + 1 == fds.size()) { 232 if (kNaClParentFDIndex + 1 == fds.size()) {
230 HandleForkRequest(fds, prereserved_sandbox_size); 233 HandleForkRequest(fds, prereserved_sandbox_size);
231 continue; // fork succeeded. Note: child does not return 234 continue; // fork succeeded. Note: child does not return
232 } else { 235 } else {
233 LOG(ERROR) << "nacl_helper: unexpected number of fds, got " 236 LOG(ERROR) << "nacl_helper: unexpected number of fds, got "
234 << fds.size(); 237 << fds.size();
235 } 238 }
236 } else { 239 } else {
237 if (msglen != 0) { 240 LOG(ERROR) << "nacl_helper unrecognized request: "
238 LOG(ERROR) << "nacl_helper unrecognized request: %s"; 241 << base::GetDoubleQuotedJson(std::string(buf, buf + msglen));
239 _exit(-1); 242 _exit(-1);
240 }
241 } 243 }
242 // if fork fails, send PID=-1 to zygote 244 // if fork fails, send PID=-1 to zygote
243 if (!UnixDomainSocket::SendMsg(kNaClZygoteDescriptor, &badpid, 245 if (!UnixDomainSocket::SendMsg(kNaClZygoteDescriptor, &badpid,
244 sizeof(badpid), empty)) { 246 sizeof(badpid), empty)) {
245 LOG(ERROR) << "*** send() to zygote failed"; 247 LOG(ERROR) << "*** send() to zygote failed";
246 } 248 }
247 } 249 }
248 CHECK(false); // This routine must not return 250 CHECK(false); // This routine must not return
249 } 251 }
OLDNEW
« 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