OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "platform/globals.h" | 5 #include "platform/globals.h" |
6 #if defined(TARGET_OS_LINUX) | 6 #if defined(TARGET_OS_LINUX) |
7 | 7 |
8 #include <errno.h> // NOLINT | 8 #include <errno.h> // NOLINT |
9 #include <stdio.h> // NOLINT | 9 #include <stdio.h> // NOLINT |
10 #include <stdlib.h> // NOLINT | 10 #include <stdlib.h> // NOLINT |
11 #include <sys/epoll.h> // NOLINT | 11 #include <sys/epoll.h> // NOLINT |
12 | 12 |
| 13 #include "platform/signal_blocker.h" |
13 #include "bin/dbg_connection.h" | 14 #include "bin/dbg_connection.h" |
14 #include "bin/fdutils.h" | 15 #include "bin/fdutils.h" |
15 #include "bin/log.h" | 16 #include "bin/log.h" |
16 #include "bin/socket.h" | 17 #include "bin/socket.h" |
17 | 18 |
18 | 19 |
19 namespace dart { | 20 namespace dart { |
20 namespace bin { | 21 namespace bin { |
21 | 22 |
22 int DebuggerConnectionImpl::epoll_fd_ = -1; | 23 int DebuggerConnectionImpl::epoll_fd_ = -1; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 ASSERT(result <= kMaxEvents); | 63 ASSERT(result <= kMaxEvents); |
63 for (int i = 0; i < result; i++) { | 64 for (int i = 0; i < result; i++) { |
64 HandleEvent(&events[i]); | 65 HandleEvent(&events[i]); |
65 } | 66 } |
66 } | 67 } |
67 } | 68 } |
68 } | 69 } |
69 | 70 |
70 | 71 |
71 void DebuggerConnectionImpl::SetupPollQueue() { | 72 void DebuggerConnectionImpl::SetupPollQueue() { |
72 int result = TEMP_FAILURE_RETRY(pipe(wakeup_fds_)); | 73 int result = NO_RETRY_EXPECTED(pipe(wakeup_fds_)); |
73 if (result != 0) { | 74 if (result != 0) { |
74 FATAL1("Pipe creation failed with error %d\n", result); | 75 FATAL1("Pipe creation failed with error %d\n", result); |
75 } | 76 } |
76 FDUtils::SetNonBlocking(wakeup_fds_[0]); | 77 FDUtils::SetNonBlocking(wakeup_fds_[0]); |
77 | 78 |
78 static const int kEpollInitialSize = 16; | 79 static const int kEpollInitialSize = 16; |
79 epoll_fd_ = TEMP_FAILURE_RETRY(epoll_create(kEpollInitialSize)); | 80 epoll_fd_ = NO_RETRY_EXPECTED(epoll_create(kEpollInitialSize)); |
80 if (epoll_fd_ == -1) { | 81 if (epoll_fd_ == -1) { |
81 FATAL("Failed creating epoll file descriptor"); | 82 FATAL("Failed creating epoll file descriptor"); |
82 } | 83 } |
83 | 84 |
84 // Register the wakeup _fd with the epoll instance. | 85 // Register the wakeup _fd with the epoll instance. |
85 struct epoll_event event; | 86 struct epoll_event event; |
86 event.events = EPOLLIN; | 87 event.events = EPOLLIN; |
87 event.data.fd = wakeup_fds_[0]; | 88 event.data.fd = wakeup_fds_[0]; |
88 int status = TEMP_FAILURE_RETRY(epoll_ctl( | 89 int status = NO_RETRY_EXPECTED(epoll_ctl( |
89 epoll_fd_, EPOLL_CTL_ADD, wakeup_fds_[0], &event)); | 90 epoll_fd_, EPOLL_CTL_ADD, wakeup_fds_[0], &event)); |
90 if (status == -1) { | 91 if (status == -1) { |
91 FATAL("Failed adding wakeup fd to epoll instance"); | 92 FATAL("Failed adding wakeup fd to epoll instance"); |
92 } | 93 } |
93 | 94 |
94 // Register the listener_fd with the epoll instance. | 95 // Register the listener_fd with the epoll instance. |
95 event.events = EPOLLIN; | 96 event.events = EPOLLIN; |
96 event.data.fd = DebuggerConnectionHandler::listener_fd_; | 97 event.data.fd = DebuggerConnectionHandler::listener_fd_; |
97 status = TEMP_FAILURE_RETRY(epoll_ctl(epoll_fd_, EPOLL_CTL_ADD, | 98 status = NO_RETRY_EXPECTED(epoll_ctl(epoll_fd_, EPOLL_CTL_ADD, |
98 DebuggerConnectionHandler::listener_fd_, &event)); | 99 DebuggerConnectionHandler::listener_fd_, &event)); |
99 if (status == -1) { | 100 if (status == -1) { |
100 FATAL("Failed adding listener fd to epoll instance"); | 101 FATAL("Failed adding listener fd to epoll instance"); |
101 } | 102 } |
102 } | 103 } |
103 | 104 |
104 | 105 |
105 void DebuggerConnectionImpl::StartHandler(int port_number) { | 106 void DebuggerConnectionImpl::StartHandler(int port_number) { |
106 ASSERT(DebuggerConnectionHandler::listener_fd_ != -1); | 107 ASSERT(DebuggerConnectionHandler::listener_fd_ != -1); |
107 SetupPollQueue(); | 108 SetupPollQueue(); |
108 int result = dart::Thread::Start(&DebuggerConnectionImpl::Handler, 0); | 109 int result = dart::Thread::Start(&DebuggerConnectionImpl::Handler, 0); |
(...skipping 11 matching lines...) Expand all Loading... |
120 | 121 |
121 | 122 |
122 intptr_t DebuggerConnectionImpl::Receive(intptr_t socket, char* buf, int len) { | 123 intptr_t DebuggerConnectionImpl::Receive(intptr_t socket, char* buf, int len) { |
123 return TEMP_FAILURE_RETRY(read(socket, buf, len)); | 124 return TEMP_FAILURE_RETRY(read(socket, buf, len)); |
124 } | 125 } |
125 | 126 |
126 } // namespace bin | 127 } // namespace bin |
127 } // namespace dart | 128 } // namespace dart |
128 | 129 |
129 #endif // defined(TARGET_OS_LINUX) | 130 #endif // defined(TARGET_OS_LINUX) |
OLD | NEW |