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_MACOS) | 8 #if defined(TARGET_OS_MACOS) |
9 | 9 |
10 #include "bin/eventhandler.h" | 10 #include "bin/eventhandler.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 } | 98 } |
99 | 99 |
100 | 100 |
101 EventHandlerImplementation::EventHandlerImplementation() | 101 EventHandlerImplementation::EventHandlerImplementation() |
102 : socket_map_(&HashMap::SamePointerValue, 16) { | 102 : socket_map_(&HashMap::SamePointerValue, 16) { |
103 intptr_t result; | 103 intptr_t result; |
104 result = NO_RETRY_EXPECTED(pipe(interrupt_fds_)); | 104 result = NO_RETRY_EXPECTED(pipe(interrupt_fds_)); |
105 if (result != 0) { | 105 if (result != 0) { |
106 FATAL("Pipe creation failed"); | 106 FATAL("Pipe creation failed"); |
107 } | 107 } |
108 FDUtils::SetNonBlocking(interrupt_fds_[0]); | 108 if (!FDUtils::SetNonBlocking(interrupt_fds_[0])) { |
109 FDUtils::SetCloseOnExec(interrupt_fds_[0]); | 109 FATAL("Failed to set pipe fd non-blocking\n"); |
110 FDUtils::SetCloseOnExec(interrupt_fds_[1]); | 110 } |
| 111 if (!FDUtils::SetCloseOnExec(interrupt_fds_[0])) { |
| 112 FATAL("Failed to set pipe fd close on exec\n"); |
| 113 } |
| 114 if (!FDUtils::SetCloseOnExec(interrupt_fds_[1])) { |
| 115 FATAL("Failed to set pipe fd close on exec\n"); |
| 116 } |
111 shutdown_ = false; | 117 shutdown_ = false; |
112 | 118 |
113 kqueue_fd_ = NO_RETRY_EXPECTED(kqueue()); | 119 kqueue_fd_ = NO_RETRY_EXPECTED(kqueue()); |
114 if (kqueue_fd_ == -1) { | 120 if (kqueue_fd_ == -1) { |
115 FATAL("Failed creating kqueue"); | 121 FATAL("Failed creating kqueue"); |
116 } | 122 } |
117 FDUtils::SetCloseOnExec(kqueue_fd_); | 123 if (!FDUtils::SetCloseOnExec(kqueue_fd_)) { |
| 124 FATAL("Failed to set kqueue fd close on exec\n"); |
| 125 } |
118 // Register the interrupt_fd with the kqueue. | 126 // Register the interrupt_fd with the kqueue. |
119 struct kevent event; | 127 struct kevent event; |
120 EV_SET(&event, interrupt_fds_[0], EVFILT_READ, EV_ADD, 0, 0, NULL); | 128 EV_SET(&event, interrupt_fds_[0], EVFILT_READ, EV_ADD, 0, 0, NULL); |
121 int status = NO_RETRY_EXPECTED(kevent(kqueue_fd_, &event, 1, NULL, 0, NULL)); | 129 int status = NO_RETRY_EXPECTED(kevent(kqueue_fd_, &event, 1, NULL, 0, NULL)); |
122 if (status == -1) { | 130 if (status == -1) { |
123 const int kBufferSize = 1024; | 131 const int kBufferSize = 1024; |
124 char error_message[kBufferSize]; | 132 char error_message[kBufferSize]; |
125 Utils::StrError(errno, error_message, kBufferSize); | 133 Utils::StrError(errno, error_message, kBufferSize); |
126 FATAL1("Failed adding interrupt fd to kqueue: %s\n", error_message); | 134 FATAL1("Failed adding interrupt fd to kqueue: %s\n", error_message); |
127 } | 135 } |
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 // The hashmap does not support keys with value 0. | 506 // The hashmap does not support keys with value 0. |
499 return dart::Utils::WordHash(fd + 1); | 507 return dart::Utils::WordHash(fd + 1); |
500 } | 508 } |
501 | 509 |
502 } // namespace bin | 510 } // namespace bin |
503 } // namespace dart | 511 } // namespace dart |
504 | 512 |
505 #endif // defined(TARGET_OS_MACOS) | 513 #endif // defined(TARGET_OS_MACOS) |
506 | 514 |
507 #endif // !defined(DART_IO_DISABLED) | 515 #endif // !defined(DART_IO_DISABLED) |
OLD | NEW |