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

Side by Side Diff: base/posix/unix_domain_socket.cc

Issue 11564030: Linux sandbox: add a new low-level broker process mechanism. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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 | sandbox/linux/sandbox_linux.gypi » ('j') | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/posix/unix_domain_socket.h" 5 #include "base/posix/unix_domain_socket.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <unistd.h> 8 #include <unistd.h>
9 #include <sys/uio.h> 9 #include <sys/uio.h>
10 #include <sys/socket.h> 10 #include <sys/socket.h>
(...skipping 25 matching lines...) Expand all
36 msg.msg_control = control_buffer; 36 msg.msg_control = control_buffer;
37 msg.msg_controllen = control_len; 37 msg.msg_controllen = control_len;
38 cmsg = CMSG_FIRSTHDR(&msg); 38 cmsg = CMSG_FIRSTHDR(&msg);
39 cmsg->cmsg_level = SOL_SOCKET; 39 cmsg->cmsg_level = SOL_SOCKET;
40 cmsg->cmsg_type = SCM_RIGHTS; 40 cmsg->cmsg_type = SCM_RIGHTS;
41 cmsg->cmsg_len = CMSG_LEN(sizeof(int) * fds.size()); 41 cmsg->cmsg_len = CMSG_LEN(sizeof(int) * fds.size());
42 memcpy(CMSG_DATA(cmsg), &fds[0], sizeof(int) * fds.size()); 42 memcpy(CMSG_DATA(cmsg), &fds[0], sizeof(int) * fds.size());
43 msg.msg_controllen = cmsg->cmsg_len; 43 msg.msg_controllen = cmsg->cmsg_len;
44 } 44 }
45 45
46 const ssize_t r = HANDLE_EINTR(sendmsg(fd, &msg, 0)); 46 // When available, take advantage of MSG_NOSIGNAL to avoid
47 // a SIGPIPE if the other end breaks the connection.
48 #if defined(MSG_NOSIGNAL)
49 const int flags = MSG_NOSIGNAL;
50 #else
51 const int flags = 0;
52 #endif
53 const ssize_t r = HANDLE_EINTR(sendmsg(fd, &msg, flags));
47 const bool ret = static_cast<ssize_t>(length) == r; 54 const bool ret = static_cast<ssize_t>(length) == r;
48 delete[] control_buffer; 55 delete[] control_buffer;
49 return ret; 56 return ret;
50 } 57 }
51 58
52 // static 59 // static
53 ssize_t UnixDomainSocket::RecvMsg(int fd, 60 ssize_t UnixDomainSocket::RecvMsg(int fd,
54 void* buf, 61 void* buf,
55 size_t length, 62 size_t length,
56 std::vector<int>* fds) { 63 std::vector<int>* fds) {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 NOTREACHED(); 144 NOTREACHED();
138 145
139 return -1; 146 return -1;
140 } 147 }
141 148
142 if (result_fd) 149 if (result_fd)
143 *result_fd = fd_vector.empty() ? -1 : fd_vector[0]; 150 *result_fd = fd_vector.empty() ? -1 : fd_vector[0];
144 151
145 return reply_len; 152 return reply_len;
146 } 153 }
OLDNEW
« no previous file with comments | « no previous file | sandbox/linux/sandbox_linux.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698