| 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 "bin/eventhandler.h" | 8 #include "bin/eventhandler.h" |
| 9 | 9 |
| 10 #include <errno.h> // NOLINT | 10 #include <errno.h> // NOLINT |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 if (events & EPOLLOUT) event_mask |= (1 << kOutEvent); | 124 if (events & EPOLLOUT) event_mask |= (1 << kOutEvent); |
| 125 if (events & (EPOLLHUP | EPOLLRDHUP)) event_mask |= (1 << kCloseEvent); | 125 if (events & (EPOLLHUP | EPOLLRDHUP)) event_mask |= (1 << kCloseEvent); |
| 126 return event_mask; | 126 return event_mask; |
| 127 } | 127 } |
| 128 | 128 |
| 129 | 129 |
| 130 void EventHandlerImplementation::HandleEvents(struct epoll_event* events, | 130 void EventHandlerImplementation::HandleEvents(struct epoll_event* events, |
| 131 int size) { | 131 int size) { |
| 132 for (int i = 0; i < size; i++) { | 132 for (int i = 0; i < size; i++) { |
| 133 uint64_t data = events[i].data.u64; | 133 uint64_t data = events[i].data.u64; |
| 134 // ILLEGAL_PORT is used to identify timer-fd. |
| 134 if (data == ILLEGAL_PORT) { | 135 if (data == ILLEGAL_PORT) { |
| 135 int64_t val; | 136 int64_t val; |
| 136 VOID_TEMP_FAILURE_RETRY(read(timer_fd_, &val, sizeof(val))); | 137 VOID_TEMP_FAILURE_RETRY(read(timer_fd_, &val, sizeof(val))); |
| 138 timer_mutex_.Lock(); |
| 137 if (timeout_queue_.HasTimeout()) { | 139 if (timeout_queue_.HasTimeout()) { |
| 138 DartUtils::PostNull(timeout_queue_.CurrentPort()); | 140 DartUtils::PostNull(timeout_queue_.CurrentPort()); |
| 139 timeout_queue_.RemoveCurrent(); | 141 timeout_queue_.RemoveCurrent(); |
| 140 } | 142 } |
| 143 timer_mutex_.Unlock(); |
| 141 } else { | 144 } else { |
| 142 int32_t event_mask = GetPollEvents(events[i].events); | 145 int32_t event_mask = GetPollEvents(events[i].events); |
| 143 if (event_mask != 0) { | 146 if (event_mask != 0) { |
| 144 Dart_Port port = data; | 147 Dart_Port port = data; |
| 145 ASSERT(port != 0); | 148 ASSERT(port != 0); |
| 146 DartUtils::PostInt32(port, event_mask); | 149 DartUtils::PostInt32(port, event_mask); |
| 147 } | 150 } |
| 148 } | 151 } |
| 149 } | 152 } |
| 150 } | 153 } |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 // Add to epoll - this is the first time we see it. | 232 // Add to epoll - this is the first time we see it. |
| 230 AddToEpollInstance(epoll_fd_, id, dart_port, data); | 233 AddToEpollInstance(epoll_fd_, id, dart_port, data); |
| 231 } | 234 } |
| 232 } | 235 } |
| 233 } | 236 } |
| 234 | 237 |
| 235 } // namespace bin | 238 } // namespace bin |
| 236 } // namespace dart | 239 } // namespace dart |
| 237 | 240 |
| 238 #endif // defined(TARGET_OS_LINUX) | 241 #endif // defined(TARGET_OS_LINUX) |
| OLD | NEW |