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 #if !defined(DART_IO_DISABLED) | 5 #if !defined(DART_IO_DISABLED) |
6 | 6 |
7 #include "platform/globals.h" | 7 #include "platform/globals.h" |
8 #if defined(TARGET_OS_LINUX) | 8 #if defined(TARGET_OS_LINUX) |
9 | 9 |
10 #include "bin/eventhandler.h" | 10 #include "bin/eventhandler.h" |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 } | 73 } |
74 | 74 |
75 | 75 |
76 EventHandlerImplementation::EventHandlerImplementation() | 76 EventHandlerImplementation::EventHandlerImplementation() |
77 : socket_map_(&HashMap::SamePointerValue, 16) { | 77 : socket_map_(&HashMap::SamePointerValue, 16) { |
78 intptr_t result; | 78 intptr_t result; |
79 result = NO_RETRY_EXPECTED(pipe(interrupt_fds_)); | 79 result = NO_RETRY_EXPECTED(pipe(interrupt_fds_)); |
80 if (result != 0) { | 80 if (result != 0) { |
81 FATAL("Pipe creation failed"); | 81 FATAL("Pipe creation failed"); |
82 } | 82 } |
83 FDUtils::SetNonBlocking(interrupt_fds_[0]); | 83 if (!FDUtils::SetNonBlocking(interrupt_fds_[0])) { |
84 FDUtils::SetCloseOnExec(interrupt_fds_[0]); | 84 FATAL("Failed to set pipe fd non blocking\n"); |
85 FDUtils::SetCloseOnExec(interrupt_fds_[1]); | 85 } |
| 86 if (!FDUtils::SetCloseOnExec(interrupt_fds_[0])) { |
| 87 FATAL("Failed to set pipe fd close on exec\n"); |
| 88 } |
| 89 if (!FDUtils::SetCloseOnExec(interrupt_fds_[1])) { |
| 90 FATAL("Failed to set pipe fd close on exec\n"); |
| 91 } |
86 shutdown_ = false; | 92 shutdown_ = false; |
87 // The initial size passed to epoll_create is ignore on newer (>= | 93 // The initial size passed to epoll_create is ignore on newer (>= |
88 // 2.6.8) Linux versions | 94 // 2.6.8) Linux versions |
89 static const int kEpollInitialSize = 64; | 95 static const int kEpollInitialSize = 64; |
90 epoll_fd_ = NO_RETRY_EXPECTED(epoll_create(kEpollInitialSize)); | 96 epoll_fd_ = NO_RETRY_EXPECTED(epoll_create(kEpollInitialSize)); |
91 if (epoll_fd_ == -1) { | 97 if (epoll_fd_ == -1) { |
92 FATAL1("Failed creating epoll file descriptor: %i", errno); | 98 FATAL1("Failed creating epoll file descriptor: %i", errno); |
93 } | 99 } |
94 FDUtils::SetCloseOnExec(epoll_fd_); | 100 if (!FDUtils::SetCloseOnExec(epoll_fd_)) { |
| 101 FATAL("Failed to set epoll fd close on exec\n"); |
| 102 } |
95 // Register the interrupt_fd with the epoll instance. | 103 // Register the interrupt_fd with the epoll instance. |
96 struct epoll_event event; | 104 struct epoll_event event; |
97 event.events = EPOLLIN; | 105 event.events = EPOLLIN; |
98 event.data.ptr = NULL; | 106 event.data.ptr = NULL; |
99 int status = NO_RETRY_EXPECTED( | 107 int status = NO_RETRY_EXPECTED( |
100 epoll_ctl(epoll_fd_, EPOLL_CTL_ADD, interrupt_fds_[0], &event)); | 108 epoll_ctl(epoll_fd_, EPOLL_CTL_ADD, interrupt_fds_[0], &event)); |
101 if (status == -1) { | 109 if (status == -1) { |
102 FATAL("Failed adding interrupt fd to epoll instance"); | 110 FATAL("Failed adding interrupt fd to epoll instance"); |
103 } | 111 } |
104 timer_fd_ = NO_RETRY_EXPECTED(timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC)); | 112 timer_fd_ = NO_RETRY_EXPECTED(timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC)); |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 // The hashmap does not support keys with value 0. | 440 // The hashmap does not support keys with value 0. |
433 return dart::Utils::WordHash(fd + 1); | 441 return dart::Utils::WordHash(fd + 1); |
434 } | 442 } |
435 | 443 |
436 } // namespace bin | 444 } // namespace bin |
437 } // namespace dart | 445 } // namespace dart |
438 | 446 |
439 #endif // defined(TARGET_OS_LINUX) | 447 #endif // defined(TARGET_OS_LINUX) |
440 | 448 |
441 #endif // !defined(DART_IO_DISABLED) | 449 #endif // !defined(DART_IO_DISABLED) |
OLD | NEW |