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