| OLD | NEW |
| 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 "ipc/ipc_channel_posix.h" | 5 #include "ipc/ipc_channel_posix.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <fcntl.h> | 8 #include <fcntl.h> |
| 9 #include <stddef.h> | 9 #include <stddef.h> |
| 10 #include <sys/socket.h> | 10 #include <sys/socket.h> |
| 11 #include <sys/stat.h> | 11 #include <sys/stat.h> |
| 12 #include <sys/types.h> | 12 #include <sys/types.h> |
| 13 #include <sys/un.h> | |
| 14 #include <unistd.h> | 13 #include <unistd.h> |
| 15 | 14 |
| 16 #if defined(OS_OPENBSD) | 15 #if defined(OS_OPENBSD) |
| 17 #include <sys/uio.h> | 16 #include <sys/uio.h> |
| 18 #endif | 17 #endif |
| 19 | 18 |
| 19 #if !defined(__native_client_nonsfi__) |
| 20 #include <sys/un.h> |
| 21 #endif |
| 22 |
| 20 #include <map> | 23 #include <map> |
| 21 #include <string> | 24 #include <string> |
| 22 | 25 |
| 23 #include "base/command_line.h" | 26 #include "base/command_line.h" |
| 24 #include "base/files/file_path.h" | 27 #include "base/files/file_path.h" |
| 25 #include "base/files/file_util.h" | 28 #include "base/files/file_util.h" |
| 26 #include "base/location.h" | 29 #include "base/location.h" |
| 27 #include "base/logging.h" | 30 #include "base/logging.h" |
| 28 #include "base/memory/scoped_ptr.h" | 31 #include "base/memory/scoped_ptr.h" |
| 29 #include "base/memory/singleton.h" | 32 #include "base/memory/singleton.h" |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 #if defined(OS_ANDROID) | 169 #if defined(OS_ANDROID) |
| 167 // When we fork for simple tests on Android, we can't 'exec', so we need to | 170 // When we fork for simple tests on Android, we can't 'exec', so we need to |
| 168 // reset these entries manually to get the expected testing behavior. | 171 // reset these entries manually to get the expected testing behavior. |
| 169 void Channel::NotifyProcessForkedForTesting() { | 172 void Channel::NotifyProcessForkedForTesting() { |
| 170 PipeMap::GetInstance()->map_.clear(); | 173 PipeMap::GetInstance()->map_.clear(); |
| 171 } | 174 } |
| 172 #endif | 175 #endif |
| 173 | 176 |
| 174 //------------------------------------------------------------------------------ | 177 //------------------------------------------------------------------------------ |
| 175 | 178 |
| 176 #if defined(OS_LINUX) | 179 #if defined(OS_LINUX) || defined(__native_client_nonsfi__) |
| 177 int ChannelPosix::global_pid_ = 0; | 180 int ChannelPosix::global_pid_ = 0; |
| 178 #endif // OS_LINUX | 181 #endif |
| 179 | 182 |
| 180 ChannelPosix::ChannelPosix(const IPC::ChannelHandle& channel_handle, | 183 ChannelPosix::ChannelPosix(const IPC::ChannelHandle& channel_handle, |
| 181 Mode mode, Listener* listener) | 184 Mode mode, Listener* listener) |
| 182 : ChannelReader(listener), | 185 : ChannelReader(listener), |
| 183 mode_(mode), | 186 mode_(mode), |
| 184 peer_pid_(base::kNullProcessId), | 187 peer_pid_(base::kNullProcessId), |
| 185 is_blocked_on_write_(false), | 188 is_blocked_on_write_(false), |
| 186 waiting_connect_(true), | 189 waiting_connect_(true), |
| 187 message_send_bytes_written_(0), | 190 message_send_bytes_written_(0), |
| 188 pipe_name_(channel_handle.name), | 191 pipe_name_(channel_handle.name), |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 if (value == -1) { | 251 if (value == -1) { |
| 249 PLOG(ERROR) << "fcntl(F_GETFL) " << pipe_name_; | 252 PLOG(ERROR) << "fcntl(F_GETFL) " << pipe_name_; |
| 250 return false; | 253 return false; |
| 251 } | 254 } |
| 252 if (!(value & O_NONBLOCK)) { | 255 if (!(value & O_NONBLOCK)) { |
| 253 LOG(ERROR) << "Socket " << pipe_name_ << " must be O_NONBLOCK"; | 256 LOG(ERROR) << "Socket " << pipe_name_ << " must be O_NONBLOCK"; |
| 254 return false; | 257 return false; |
| 255 } | 258 } |
| 256 #endif // IPC_USES_READWRITE | 259 #endif // IPC_USES_READWRITE |
| 257 } else if (mode_ & MODE_NAMED_FLAG) { | 260 } else if (mode_ & MODE_NAMED_FLAG) { |
| 261 #if defined(__native_client_nonsfi__) |
| 262 // IPC channels in nacl_helper_nonsfi should not be NAMED mode. |
| 263 NOTREACHED(); |
| 264 return false; |
| 265 #else |
| 258 // Case 2 from comment above. | 266 // Case 2 from comment above. |
| 259 int local_pipe_fd = -1; | 267 int local_pipe_fd = -1; |
| 260 | 268 |
| 261 if (mode_ & MODE_SERVER_FLAG) { | 269 if (mode_ & MODE_SERVER_FLAG) { |
| 262 if (!CreateServerUnixDomainSocket(base::FilePath(pipe_name_), | 270 if (!CreateServerUnixDomainSocket(base::FilePath(pipe_name_), |
| 263 &local_pipe_fd)) { | 271 &local_pipe_fd)) { |
| 264 return false; | 272 return false; |
| 265 } | 273 } |
| 266 | 274 |
| 267 must_unlink_ = true; | 275 must_unlink_ = true; |
| 268 } else if (mode_ & MODE_CLIENT_FLAG) { | 276 } else if (mode_ & MODE_CLIENT_FLAG) { |
| 269 if (!CreateClientUnixDomainSocket(base::FilePath(pipe_name_), | 277 if (!CreateClientUnixDomainSocket(base::FilePath(pipe_name_), |
| 270 &local_pipe_fd)) { | 278 &local_pipe_fd)) { |
| 271 return false; | 279 return false; |
| 272 } | 280 } |
| 273 } else { | 281 } else { |
| 274 LOG(ERROR) << "Bad mode: " << mode_; | 282 LOG(ERROR) << "Bad mode: " << mode_; |
| 275 return false; | 283 return false; |
| 276 } | 284 } |
| 277 | 285 |
| 278 local_pipe.reset(local_pipe_fd); | 286 local_pipe.reset(local_pipe_fd); |
| 287 #endif // !defined(__native_client_nonsfi__) |
| 279 } else { | 288 } else { |
| 280 local_pipe.reset(PipeMap::GetInstance()->Lookup(pipe_name_)); | 289 local_pipe.reset(PipeMap::GetInstance()->Lookup(pipe_name_)); |
| 281 if (mode_ & MODE_CLIENT_FLAG) { | 290 if (mode_ & MODE_CLIENT_FLAG) { |
| 282 if (local_pipe.is_valid()) { | 291 if (local_pipe.is_valid()) { |
| 283 // Case 3 from comment above. | 292 // Case 3 from comment above. |
| 284 // We only allow one connection. | 293 // We only allow one connection. |
| 285 local_pipe.reset(HANDLE_EINTR(dup(local_pipe.release()))); | 294 local_pipe.reset(HANDLE_EINTR(dup(local_pipe.release()))); |
| 286 PipeMap::GetInstance()->Remove(pipe_name_); | 295 PipeMap::GetInstance()->Remove(pipe_name_); |
| 287 } else { | 296 } else { |
| 288 // Case 4a from comment above. | 297 // Case 4a from comment above. |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 int fd_pipe_fd = 1, remote_fd_pipe_fd = -1; | 338 int fd_pipe_fd = 1, remote_fd_pipe_fd = -1; |
| 330 if (!SocketPair(&fd_pipe_fd, &remote_fd_pipe_fd)) { | 339 if (!SocketPair(&fd_pipe_fd, &remote_fd_pipe_fd)) { |
| 331 return false; | 340 return false; |
| 332 } | 341 } |
| 333 | 342 |
| 334 fd_pipe_.reset(fd_pipe_fd); | 343 fd_pipe_.reset(fd_pipe_fd); |
| 335 remote_fd_pipe_.reset(remote_fd_pipe_fd); | 344 remote_fd_pipe_.reset(remote_fd_pipe_fd); |
| 336 } | 345 } |
| 337 #endif // IPC_USES_READWRITE | 346 #endif // IPC_USES_READWRITE |
| 338 | 347 |
| 339 if ((mode_ & MODE_SERVER_FLAG) && (mode_ & MODE_NAMED_FLAG)) | 348 if ((mode_ & MODE_SERVER_FLAG) && (mode_ & MODE_NAMED_FLAG)) { |
| 349 #if defined(__native_client_nonsfi__) |
| 350 // IPC channels in nacl_helper_nonsfi should not be NAMED or SERVER mode. |
| 351 NOTREACHED(); |
| 352 #else |
| 340 server_listen_pipe_.reset(local_pipe.release()); | 353 server_listen_pipe_.reset(local_pipe.release()); |
| 341 else | 354 #endif |
| 355 } else { |
| 342 pipe_.reset(local_pipe.release()); | 356 pipe_.reset(local_pipe.release()); |
| 357 } |
| 343 return true; | 358 return true; |
| 344 } | 359 } |
| 345 | 360 |
| 346 bool ChannelPosix::Connect() { | 361 bool ChannelPosix::Connect() { |
| 347 if (!server_listen_pipe_.is_valid() && !pipe_.is_valid()) { | 362 if (!server_listen_pipe_.is_valid() && !pipe_.is_valid()) { |
| 348 DLOG(WARNING) << "Channel creation failed: " << pipe_name_; | 363 DLOG(WARNING) << "Channel creation failed: " << pipe_name_; |
| 349 return false; | 364 return false; |
| 350 } | 365 } |
| 351 | 366 |
| 352 bool did_connect = true; | 367 bool did_connect = true; |
| 353 if (server_listen_pipe_.is_valid()) { | 368 if (server_listen_pipe_.is_valid()) { |
| 369 #if defined(__native_client_nonsfi__) |
| 370 // IPC channels in nacl_helper_nonsfi should always be client mode. |
| 371 NOTREACHED(); |
| 372 #else |
| 354 // Watch the pipe for connections, and turn any connections into | 373 // Watch the pipe for connections, and turn any connections into |
| 355 // active sockets. | 374 // active sockets. |
| 356 base::MessageLoopForIO::current()->WatchFileDescriptor( | 375 base::MessageLoopForIO::current()->WatchFileDescriptor( |
| 357 server_listen_pipe_.get(), | 376 server_listen_pipe_.get(), |
| 358 true, | 377 true, |
| 359 base::MessageLoopForIO::WATCH_READ, | 378 base::MessageLoopForIO::WATCH_READ, |
| 360 &server_listen_connection_watcher_, | 379 &server_listen_connection_watcher_, |
| 361 this); | 380 this); |
| 381 #endif |
| 362 } else { | 382 } else { |
| 363 did_connect = AcceptConnection(); | 383 did_connect = AcceptConnection(); |
| 364 } | 384 } |
| 365 return did_connect; | 385 return did_connect; |
| 366 } | 386 } |
| 367 | 387 |
| 368 void ChannelPosix::CloseFileDescriptors(Message* msg) { | 388 void ChannelPosix::CloseFileDescriptors(Message* msg) { |
| 369 #if defined(OS_MACOSX) | 389 #if defined(OS_MACOSX) |
| 370 // There is a bug on OSX which makes it dangerous to close | 390 // There is a bug on OSX which makes it dangerous to close |
| 371 // a file descriptor while it is in transit. So instead we | 391 // a file descriptor while it is in transit. So instead we |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 574 } | 594 } |
| 575 | 595 |
| 576 bool ChannelPosix::AcceptsConnections() const { | 596 bool ChannelPosix::AcceptsConnections() const { |
| 577 return server_listen_pipe_.is_valid(); | 597 return server_listen_pipe_.is_valid(); |
| 578 } | 598 } |
| 579 | 599 |
| 580 bool ChannelPosix::HasAcceptedConnection() const { | 600 bool ChannelPosix::HasAcceptedConnection() const { |
| 581 return AcceptsConnections() && pipe_.is_valid(); | 601 return AcceptsConnections() && pipe_.is_valid(); |
| 582 } | 602 } |
| 583 | 603 |
| 604 #if !defined(__native_client_nonsfi__) |
| 605 // GetPeerEuid is not supported in nacl_helper_nonsfi. |
| 584 bool ChannelPosix::GetPeerEuid(uid_t* peer_euid) const { | 606 bool ChannelPosix::GetPeerEuid(uid_t* peer_euid) const { |
| 585 DCHECK(!(mode_ & MODE_SERVER) || HasAcceptedConnection()); | 607 DCHECK(!(mode_ & MODE_SERVER) || HasAcceptedConnection()); |
| 586 return IPC::GetPeerEuid(pipe_.get(), peer_euid); | 608 return IPC::GetPeerEuid(pipe_.get(), peer_euid); |
| 587 } | 609 } |
| 610 #endif |
| 588 | 611 |
| 589 void ChannelPosix::ResetToAcceptingConnectionState() { | 612 void ChannelPosix::ResetToAcceptingConnectionState() { |
| 590 // Unregister libevent for the unix domain socket and close it. | 613 // Unregister libevent for the unix domain socket and close it. |
| 591 read_watcher_.StopWatchingFileDescriptor(); | 614 read_watcher_.StopWatchingFileDescriptor(); |
| 592 write_watcher_.StopWatchingFileDescriptor(); | 615 write_watcher_.StopWatchingFileDescriptor(); |
| 593 pipe_.reset(); | 616 pipe_.reset(); |
| 594 #if defined(IPC_USES_READWRITE) | 617 #if defined(IPC_USES_READWRITE) |
| 595 fd_pipe_.reset(); | 618 fd_pipe_.reset(); |
| 596 remote_fd_pipe_.reset(); | 619 remote_fd_pipe_.reset(); |
| 597 #endif // IPC_USES_READWRITE | 620 #endif // IPC_USES_READWRITE |
| (...skipping 18 matching lines...) Expand all Loading... |
| 616 fds_to_close_.clear(); | 639 fds_to_close_.clear(); |
| 617 #endif | 640 #endif |
| 618 } | 641 } |
| 619 | 642 |
| 620 // static | 643 // static |
| 621 bool ChannelPosix::IsNamedServerInitialized( | 644 bool ChannelPosix::IsNamedServerInitialized( |
| 622 const std::string& channel_id) { | 645 const std::string& channel_id) { |
| 623 return base::PathExists(base::FilePath(channel_id)); | 646 return base::PathExists(base::FilePath(channel_id)); |
| 624 } | 647 } |
| 625 | 648 |
| 626 #if defined(OS_LINUX) | 649 #if defined(OS_LINUX) || defined(__native_client_nonsfi__) |
| 627 // static | 650 // static |
| 628 void ChannelPosix::SetGlobalPid(int pid) { | 651 void ChannelPosix::SetGlobalPid(int pid) { |
| 629 global_pid_ = pid; | 652 global_pid_ = pid; |
| 630 } | 653 } |
| 631 #endif // OS_LINUX | 654 #endif |
| 632 | 655 |
| 633 // Called by libevent when we can read from the pipe without blocking. | 656 // Called by libevent when we can read from the pipe without blocking. |
| 634 void ChannelPosix::OnFileCanReadWithoutBlocking(int fd) { | 657 void ChannelPosix::OnFileCanReadWithoutBlocking(int fd) { |
| 635 if (fd == server_listen_pipe_.get()) { | 658 if (fd == server_listen_pipe_.get()) { |
| 659 #if defined(__native_client_nonsfi__) |
| 660 // IPC channels in nacl_helper_nonsfi should not be SERVER mode. |
| 661 NOTREACHED(); |
| 662 #else |
| 636 int new_pipe = 0; | 663 int new_pipe = 0; |
| 637 if (!ServerAcceptConnection(server_listen_pipe_.get(), &new_pipe) || | 664 if (!ServerAcceptConnection(server_listen_pipe_.get(), &new_pipe) || |
| 638 new_pipe < 0) { | 665 new_pipe < 0) { |
| 639 Close(); | 666 Close(); |
| 640 listener()->OnChannelListenError(); | 667 listener()->OnChannelListenError(); |
| 641 } | 668 } |
| 642 | 669 |
| 643 if (pipe_.is_valid()) { | 670 if (pipe_.is_valid()) { |
| 644 // We already have a connection. We only handle one at a time. | 671 // We already have a connection. We only handle one at a time. |
| 645 // close our new descriptor. | 672 // close our new descriptor. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 664 DLOG(WARNING) << "Client euid is not authorised"; | 691 DLOG(WARNING) << "Client euid is not authorised"; |
| 665 ResetToAcceptingConnectionState(); | 692 ResetToAcceptingConnectionState(); |
| 666 return; | 693 return; |
| 667 } | 694 } |
| 668 } | 695 } |
| 669 | 696 |
| 670 if (!AcceptConnection()) { | 697 if (!AcceptConnection()) { |
| 671 NOTREACHED() << "AcceptConnection should not fail on server"; | 698 NOTREACHED() << "AcceptConnection should not fail on server"; |
| 672 } | 699 } |
| 673 waiting_connect_ = false; | 700 waiting_connect_ = false; |
| 701 #endif |
| 674 } else if (fd == pipe_) { | 702 } else if (fd == pipe_) { |
| 675 if (waiting_connect_ && (mode_ & MODE_SERVER_FLAG)) { | 703 if (waiting_connect_ && (mode_ & MODE_SERVER_FLAG)) { |
| 676 waiting_connect_ = false; | 704 waiting_connect_ = false; |
| 677 } | 705 } |
| 678 if (!ProcessIncomingMessages()) { | 706 if (!ProcessIncomingMessages()) { |
| 679 // ClosePipeOnError may delete this object, so we mustn't call | 707 // ClosePipeOnError may delete this object, so we mustn't call |
| 680 // ProcessOutgoingMessages. | 708 // ProcessOutgoingMessages. |
| 681 ClosePipeOnError(); | 709 ClosePipeOnError(); |
| 682 return; | 710 return; |
| 683 } | 711 } |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 Close(); | 765 Close(); |
| 738 if (AcceptsConnections()) { | 766 if (AcceptsConnections()) { |
| 739 listener()->OnChannelListenError(); | 767 listener()->OnChannelListenError(); |
| 740 } else { | 768 } else { |
| 741 listener()->OnChannelError(); | 769 listener()->OnChannelError(); |
| 742 } | 770 } |
| 743 } | 771 } |
| 744 } | 772 } |
| 745 | 773 |
| 746 int ChannelPosix::GetHelloMessageProcId() const { | 774 int ChannelPosix::GetHelloMessageProcId() const { |
| 747 int pid = base::GetCurrentProcId(); | 775 // Our process may be in a sandbox with a separate PID namespace. |
| 776 #if defined(__native_client_nonsfi__) |
| 777 // In nacl_helper_nonsfi, our process should be always in the sandbox, unless |
| 778 // --no-sandbox is set. In such a situation, calling GetCurrentProcId() |
| 779 // would hit the sandbox restriction. global_pid_ should be initialize at |
| 780 // the very beginning of the nacl_helper_nonsfi, regardless of the |
| 781 // --no-sandbox flag. |
| 782 CHECK(global_pid_); |
| 783 return global_pid_; |
| 784 #else |
| 748 #if defined(OS_LINUX) | 785 #if defined(OS_LINUX) |
| 749 // Our process may be in a sandbox with a separate PID namespace. | |
| 750 if (global_pid_) { | 786 if (global_pid_) { |
| 751 pid = global_pid_; | 787 return global_pid_; |
| 752 } | 788 } |
| 753 #endif | 789 // Fall through to below. |
| 754 return pid; | 790 #endif // defined(OS_LINUX) |
| 791 return base::GetCurrentProcId(); |
| 792 #endif // defined(__native_client_nonsfi__) |
| 755 } | 793 } |
| 756 | 794 |
| 757 void ChannelPosix::QueueHelloMessage() { | 795 void ChannelPosix::QueueHelloMessage() { |
| 758 // Create the Hello message | 796 // Create the Hello message |
| 759 scoped_ptr<Message> msg(new Message(MSG_ROUTING_NONE, | 797 scoped_ptr<Message> msg(new Message(MSG_ROUTING_NONE, |
| 760 HELLO_MESSAGE_TYPE, | 798 HELLO_MESSAGE_TYPE, |
| 761 IPC::Message::PRIORITY_NORMAL)); | 799 IPC::Message::PRIORITY_NORMAL)); |
| 762 if (!msg->WriteInt(GetHelloMessageProcId())) { | 800 if (!msg->WriteInt(GetHelloMessageProcId())) { |
| 763 NOTREACHED() << "Unable to pickle hello message proc id"; | 801 NOTREACHED() << "Unable to pickle hello message proc id"; |
| 764 } | 802 } |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 916 cmsg = CMSG_NXTHDR(msg, cmsg)) { | 954 cmsg = CMSG_NXTHDR(msg, cmsg)) { |
| 917 if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_RIGHTS) { | 955 if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_RIGHTS) { |
| 918 unsigned payload_len = cmsg->cmsg_len - CMSG_LEN(0); | 956 unsigned payload_len = cmsg->cmsg_len - CMSG_LEN(0); |
| 919 DCHECK_EQ(0U, payload_len % sizeof(int)); | 957 DCHECK_EQ(0U, payload_len % sizeof(int)); |
| 920 const int* file_descriptors = reinterpret_cast<int*>(CMSG_DATA(cmsg)); | 958 const int* file_descriptors = reinterpret_cast<int*>(CMSG_DATA(cmsg)); |
| 921 unsigned num_file_descriptors = payload_len / 4; | 959 unsigned num_file_descriptors = payload_len / 4; |
| 922 input_fds_.insert(input_fds_.end(), | 960 input_fds_.insert(input_fds_.end(), |
| 923 file_descriptors, | 961 file_descriptors, |
| 924 file_descriptors + num_file_descriptors); | 962 file_descriptors + num_file_descriptors); |
| 925 | 963 |
| 964 #if !defined(__native_client_nonsfi__) |
| 965 // The PNaCl toolchain for Non-SFI binary build does not support |
| 966 // MSG_CTRUNC. |
| 926 // Check this after adding the FDs so we don't leak them. | 967 // Check this after adding the FDs so we don't leak them. |
| 927 if (msg->msg_flags & MSG_CTRUNC) { | 968 if (msg->msg_flags & MSG_CTRUNC) { |
| 928 ClearInputFDs(); | 969 ClearInputFDs(); |
| 929 return false; | 970 return false; |
| 930 } | 971 } |
| 972 #endif |
| 931 | 973 |
| 932 return true; | 974 return true; |
| 933 } | 975 } |
| 934 } | 976 } |
| 935 | 977 |
| 936 // No file descriptors found, but that's OK. | 978 // No file descriptors found, but that's OK. |
| 937 return true; | 979 return true; |
| 938 } | 980 } |
| 939 | 981 |
| 940 void ChannelPosix::ClearInputFDs() { | 982 void ChannelPosix::ClearInputFDs() { |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1025 // idempotent. | 1067 // idempotent. |
| 1026 | 1068 |
| 1027 ResetToAcceptingConnectionState(); | 1069 ResetToAcceptingConnectionState(); |
| 1028 | 1070 |
| 1029 if (must_unlink_) { | 1071 if (must_unlink_) { |
| 1030 unlink(pipe_name_.c_str()); | 1072 unlink(pipe_name_.c_str()); |
| 1031 must_unlink_ = false; | 1073 must_unlink_ = false; |
| 1032 } | 1074 } |
| 1033 | 1075 |
| 1034 if (server_listen_pipe_.is_valid()) { | 1076 if (server_listen_pipe_.is_valid()) { |
| 1077 #if defined(__native_client_nonsfi__) |
| 1078 // IPC channels in nacl_helper_nonsfi should not be SERVER mode. |
| 1079 NOTREACHED(); |
| 1080 #else |
| 1035 server_listen_pipe_.reset(); | 1081 server_listen_pipe_.reset(); |
| 1036 // Unregister libevent for the listening socket and close it. | 1082 // Unregister libevent for the listening socket and close it. |
| 1037 server_listen_connection_watcher_.StopWatchingFileDescriptor(); | 1083 server_listen_connection_watcher_.StopWatchingFileDescriptor(); |
| 1084 #endif |
| 1038 } | 1085 } |
| 1039 | 1086 |
| 1040 CloseClientFileDescriptor(); | 1087 CloseClientFileDescriptor(); |
| 1041 } | 1088 } |
| 1042 | 1089 |
| 1043 base::ProcessId ChannelPosix::GetPeerPID() const { | 1090 base::ProcessId ChannelPosix::GetPeerPID() const { |
| 1044 return peer_pid_; | 1091 return peer_pid_; |
| 1045 } | 1092 } |
| 1046 | 1093 |
| 1047 base::ProcessId ChannelPosix::GetSelfPID() const { | 1094 base::ProcessId ChannelPosix::GetSelfPID() const { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1068 | 1115 |
| 1069 return id.append(GenerateUniqueRandomChannelID()); | 1116 return id.append(GenerateUniqueRandomChannelID()); |
| 1070 } | 1117 } |
| 1071 | 1118 |
| 1072 | 1119 |
| 1073 bool Channel::IsNamedServerInitialized( | 1120 bool Channel::IsNamedServerInitialized( |
| 1074 const std::string& channel_id) { | 1121 const std::string& channel_id) { |
| 1075 return ChannelPosix::IsNamedServerInitialized(channel_id); | 1122 return ChannelPosix::IsNamedServerInitialized(channel_id); |
| 1076 } | 1123 } |
| 1077 | 1124 |
| 1078 #if defined(OS_LINUX) | 1125 #if defined(OS_LINUX) || defined(__native_client_nonsfi__) |
| 1079 // static | 1126 // static |
| 1080 void Channel::SetGlobalPid(int pid) { | 1127 void Channel::SetGlobalPid(int pid) { |
| 1081 ChannelPosix::SetGlobalPid(pid); | 1128 ChannelPosix::SetGlobalPid(pid); |
| 1082 } | 1129 } |
| 1083 #endif // OS_LINUX | 1130 #endif |
| 1084 | 1131 |
| 1085 } // namespace IPC | 1132 } // namespace IPC |
| OLD | NEW |