| 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 struct epoll_event event; | 127 struct epoll_event event; |
| 128 event.events = EPOLLIN; | 128 event.events = EPOLLIN; |
| 129 event.data.ptr = NULL; | 129 event.data.ptr = NULL; |
| 130 int status = TEMP_FAILURE_RETRY(epoll_ctl(epoll_fd_, | 130 int status = TEMP_FAILURE_RETRY(epoll_ctl(epoll_fd_, |
| 131 EPOLL_CTL_ADD, | 131 EPOLL_CTL_ADD, |
| 132 interrupt_fds_[0], | 132 interrupt_fds_[0], |
| 133 &event)); | 133 &event)); |
| 134 if (status == -1) { | 134 if (status == -1) { |
| 135 FATAL("Failed adding interrupt fd to epoll instance"); | 135 FATAL("Failed adding interrupt fd to epoll instance"); |
| 136 } | 136 } |
| 137 timer_fd_ = TEMP_FAILURE_RETRY(timerfd_create(CLOCK_REALTIME, | 137 timer_fd_ = TEMP_FAILURE_RETRY(timerfd_create(CLOCK_REALTIME, TFD_CLOEXEC)); |
| 138 TFD_NONBLOCK | TFD_CLOEXEC)); | |
| 139 if (epoll_fd_ == -1) { | 138 if (epoll_fd_ == -1) { |
| 140 FATAL("Failed creating timerfd file descriptor"); | 139 FATAL("Failed creating timerfd file descriptor"); |
| 141 } | 140 } |
| 142 // Register the timer_fd_ with the epoll instance. | 141 // Register the timer_fd_ with the epoll instance. |
| 143 event.events = EPOLLIN; | 142 event.events = EPOLLIN; |
| 144 event.data.fd = timer_fd_; | 143 event.data.fd = timer_fd_; |
| 145 status = TEMP_FAILURE_RETRY(epoll_ctl(epoll_fd_, | 144 status = TEMP_FAILURE_RETRY(epoll_ctl(epoll_fd_, |
| 146 EPOLL_CTL_ADD, | 145 EPOLL_CTL_ADD, |
| 147 timer_fd_, | 146 timer_fd_, |
| 148 &event)); | 147 &event)); |
| 149 if (status == -1) { | 148 if (status == -1) { |
| 150 FATAL("Failed adding timerfd fd to epoll instance"); | 149 FATAL2( |
| 150 "Failed adding timerfd fd(%i) to epoll instance: %i", timer_fd_, errno); |
| 151 } | 151 } |
| 152 } | 152 } |
| 153 | 153 |
| 154 | 154 |
| 155 EventHandlerImplementation::~EventHandlerImplementation() { | 155 EventHandlerImplementation::~EventHandlerImplementation() { |
| 156 TEMP_FAILURE_RETRY(close(epoll_fd_)); | 156 TEMP_FAILURE_RETRY(close(epoll_fd_)); |
| 157 TEMP_FAILURE_RETRY(close(timer_fd_)); | 157 TEMP_FAILURE_RETRY(close(timer_fd_)); |
| 158 TEMP_FAILURE_RETRY(close(interrupt_fds_[0])); | 158 TEMP_FAILURE_RETRY(close(interrupt_fds_[0])); |
| 159 TEMP_FAILURE_RETRY(close(interrupt_fds_[1])); | 159 TEMP_FAILURE_RETRY(close(interrupt_fds_[1])); |
| 160 } | 160 } |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 | 443 |
| 444 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { | 444 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { |
| 445 // The hashmap does not support keys with value 0. | 445 // The hashmap does not support keys with value 0. |
| 446 return dart::Utils::WordHash(fd + 1); | 446 return dart::Utils::WordHash(fd + 1); |
| 447 } | 447 } |
| 448 | 448 |
| 449 } // namespace bin | 449 } // namespace bin |
| 450 } // namespace dart | 450 } // namespace dart |
| 451 | 451 |
| 452 #endif // defined(TARGET_OS_LINUX) | 452 #endif // defined(TARGET_OS_LINUX) |
| OLD | NEW |