| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 } | 57 } |
| 58 } | 58 } |
| 59 | 59 |
| 60 | 60 |
| 61 EventHandlerImplementation::EventHandlerImplementation() : shutdown_(false) { | 61 EventHandlerImplementation::EventHandlerImplementation() : shutdown_(false) { |
| 62 // The initial size passed to epoll_create is ignore on newer (>= | 62 // The initial size passed to epoll_create is ignore on newer (>= |
| 63 // 2.6.8) Linux versions | 63 // 2.6.8) Linux versions |
| 64 static const int kEpollInitialSize = 64; | 64 static const int kEpollInitialSize = 64; |
| 65 epoll_fd_ = TEMP_FAILURE_RETRY(epoll_create(kEpollInitialSize)); | 65 epoll_fd_ = TEMP_FAILURE_RETRY(epoll_create(kEpollInitialSize)); |
| 66 if (epoll_fd_ == -1) { | 66 if (epoll_fd_ == -1) { |
| 67 FATAL("Failed creating epoll file descriptor"); | 67 FATAL1("Failed creating epoll file descriptor: %i", errno); |
| 68 } | 68 } |
| 69 FDUtils::SetCloseOnExec(epoll_fd_); | 69 FDUtils::SetCloseOnExec(epoll_fd_); |
| 70 timer_fd_ = TEMP_FAILURE_RETRY(timerfd_create(CLOCK_REALTIME, TFD_CLOEXEC)); | 70 timer_fd_ = TEMP_FAILURE_RETRY(timerfd_create(CLOCK_REALTIME, TFD_CLOEXEC)); |
| 71 if (epoll_fd_ == -1) { | 71 if (timer_fd_ == -1) { |
| 72 FATAL("Failed creating timerfd file descriptor"); | 72 FATAL1("Failed creating timerfd file descriptor: %i", errno); |
| 73 } | 73 } |
| 74 // Register the timer_fd_ with the epoll instance. | 74 // Register the timer_fd_ with the epoll instance. |
| 75 struct epoll_event event; | 75 struct epoll_event event; |
| 76 event.events = EPOLLIN; | 76 event.events = EPOLLIN; |
| 77 event.data.u64 = ILLEGAL_PORT; // Use ILLEGAL_PORT to identify timer-fd. | 77 event.data.u64 = ILLEGAL_PORT; // Use ILLEGAL_PORT to identify timer-fd. |
| 78 int status = TEMP_FAILURE_RETRY(epoll_ctl(epoll_fd_, | 78 int status = TEMP_FAILURE_RETRY(epoll_ctl(epoll_fd_, |
| 79 EPOLL_CTL_ADD, | 79 EPOLL_CTL_ADD, |
| 80 timer_fd_, | 80 timer_fd_, |
| 81 &event)); | 81 &event)); |
| 82 if (status == -1) { | 82 if (status == -1) { |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 // Add to epoll - this is the first time we see it. | 232 // Add to epoll - this is the first time we see it. |
| 233 AddToEpollInstance(epoll_fd_, id, dart_port, data); | 233 AddToEpollInstance(epoll_fd_, id, dart_port, data); |
| 234 } | 234 } |
| 235 } | 235 } |
| 236 } | 236 } |
| 237 | 237 |
| 238 } // namespace bin | 238 } // namespace bin |
| 239 } // namespace dart | 239 } // namespace dart |
| 240 | 240 |
| 241 #endif // defined(TARGET_OS_LINUX) | 241 #endif // defined(TARGET_OS_LINUX) |
| OLD | NEW |