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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 int status = NO_RETRY_EXPECTED(kevent(kqueue_fd_, &event, 1, NULL, 0, NULL)); | 133 int status = NO_RETRY_EXPECTED(kevent(kqueue_fd_, &event, 1, NULL, 0, NULL)); |
134 if (status == -1) { | 134 if (status == -1) { |
135 const int kBufferSize = 1024; | 135 const int kBufferSize = 1024; |
136 char error_message[kBufferSize]; | 136 char error_message[kBufferSize]; |
137 Utils::StrError(errno, error_message, kBufferSize); | 137 Utils::StrError(errno, error_message, kBufferSize); |
138 FATAL1("Failed adding interrupt fd to kqueue: %s\n", error_message); | 138 FATAL1("Failed adding interrupt fd to kqueue: %s\n", error_message); |
139 } | 139 } |
140 } | 140 } |
141 | 141 |
142 | 142 |
| 143 static void DeleteDescriptorInfo(void* info) { |
| 144 DescriptorInfo* di = reinterpret_cast<DescriptorInfo*>(info); |
| 145 di->Close(); |
| 146 delete di; |
| 147 } |
| 148 |
| 149 |
143 EventHandlerImplementation::~EventHandlerImplementation() { | 150 EventHandlerImplementation::~EventHandlerImplementation() { |
| 151 socket_map_.Clear(DeleteDescriptorInfo); |
144 VOID_TEMP_FAILURE_RETRY(close(kqueue_fd_)); | 152 VOID_TEMP_FAILURE_RETRY(close(kqueue_fd_)); |
145 VOID_TEMP_FAILURE_RETRY(close(interrupt_fds_[0])); | 153 VOID_TEMP_FAILURE_RETRY(close(interrupt_fds_[0])); |
146 VOID_TEMP_FAILURE_RETRY(close(interrupt_fds_[1])); | 154 VOID_TEMP_FAILURE_RETRY(close(interrupt_fds_[1])); |
147 } | 155 } |
148 | 156 |
149 | 157 |
150 void EventHandlerImplementation::UpdateKQueueInstance(intptr_t old_mask, | 158 void EventHandlerImplementation::UpdateKQueueInstance(intptr_t old_mask, |
151 DescriptorInfo *di) { | 159 DescriptorInfo *di) { |
152 intptr_t new_mask = di->Mask(); | 160 intptr_t new_mask = di->Mask(); |
153 if (old_mask != 0 && new_mask == 0) { | 161 if (old_mask != 0 && new_mask == 0) { |
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 // The hashmap does not support keys with value 0. | 514 // The hashmap does not support keys with value 0. |
507 return dart::Utils::WordHash(fd + 1); | 515 return dart::Utils::WordHash(fd + 1); |
508 } | 516 } |
509 | 517 |
510 } // namespace bin | 518 } // namespace bin |
511 } // namespace dart | 519 } // namespace dart |
512 | 520 |
513 #endif // defined(TARGET_OS_MACOS) | 521 #endif // defined(TARGET_OS_MACOS) |
514 | 522 |
515 #endif // !defined(DART_IO_DISABLED) | 523 #endif // !defined(DART_IO_DISABLED) |
OLD | NEW |