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 "tools/android/forwarder2/pipe_notifier.h" | 5 #include "tools/android/forwarder2/pipe_notifier.h" |
6 | 6 |
7 #include <fcntl.h> | 7 #include <fcntl.h> |
8 #include <unistd.h> | 8 #include <unistd.h> |
9 #include <sys/socket.h> | 9 #include <sys/socket.h> |
10 #include <sys/types.h> | 10 #include <sys/types.h> |
11 | 11 |
12 #include "base/logging.h" | 12 #include "base/logging.h" |
13 #include "base/posix/eintr_wrapper.h" | 13 #include "base/posix/eintr_wrapper.h" |
14 #include "base/safe_strerror_posix.h" | |
15 | 14 |
16 namespace forwarder2 { | 15 namespace forwarder2 { |
17 | 16 |
18 PipeNotifier::PipeNotifier() { | 17 PipeNotifier::PipeNotifier() { |
19 int pipe_fd[2]; | 18 int pipe_fd[2]; |
20 int ret = pipe(pipe_fd); | 19 int ret = pipe(pipe_fd); |
21 CHECK_EQ(0, ret); | 20 CHECK_EQ(0, ret); |
22 receiver_fd_ = pipe_fd[0]; | 21 receiver_fd_ = pipe_fd[0]; |
23 sender_fd_ = pipe_fd[1]; | 22 sender_fd_ = pipe_fd[1]; |
24 fcntl(sender_fd_, F_SETFL, O_NONBLOCK); | 23 fcntl(sender_fd_, F_SETFL, O_NONBLOCK); |
(...skipping 20 matching lines...) Expand all Loading... |
45 int ret = HANDLE_EINTR(read(receiver_fd_, &c, 1)); | 44 int ret = HANDLE_EINTR(read(receiver_fd_, &c, 1)); |
46 if (ret < 0) { | 45 if (ret < 0) { |
47 PLOG(ERROR) << "read"; | 46 PLOG(ERROR) << "read"; |
48 return; | 47 return; |
49 } | 48 } |
50 DCHECK_EQ(1, ret); | 49 DCHECK_EQ(1, ret); |
51 DCHECK_EQ('1', c); | 50 DCHECK_EQ('1', c); |
52 } | 51 } |
53 | 52 |
54 } // namespace forwarder | 53 } // namespace forwarder |
OLD | NEW |