| 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_MACOS) | 6 #if defined(TARGET_OS_MACOS) |
| 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 EV_SET(events + changes, sd->fd(), EVFILT_WRITE, EV_DELETE, 0, 0, NULL); | 95 EV_SET(events + changes, sd->fd(), EVFILT_WRITE, EV_DELETE, 0, 0, NULL); |
| 96 ++changes; | 96 ++changes; |
| 97 sd->set_write_tracked_by_kqueue(false); | 97 sd->set_write_tracked_by_kqueue(false); |
| 98 } | 98 } |
| 99 } | 99 } |
| 100 if (changes > 0) { | 100 if (changes > 0) { |
| 101 ASSERT(changes <= kMaxChanges); | 101 ASSERT(changes <= kMaxChanges); |
| 102 int status = | 102 int status = |
| 103 TEMP_FAILURE_RETRY(kevent(kqueue_fd_, events, changes, NULL, 0, NULL)); | 103 TEMP_FAILURE_RETRY(kevent(kqueue_fd_, events, changes, NULL, 0, NULL)); |
| 104 if (status == -1) { | 104 if (status == -1) { |
| 105 FATAL1("Failed updating kqueue: %s\n", strerror(errno)); | 105 // kQueue does not accept the file descriptor. It could be due to |
| 106 // already closed file descriptor, or unuspported devices, such |
| 107 // as /dev/null. In such case, mark the file descriptor as closed, |
| 108 // so dart will handle it accordingly. |
| 109 sd->set_write_tracked_by_kqueue(false); |
| 110 sd->set_read_tracked_by_kqueue(false); |
| 111 sd->ShutdownRead(); |
| 112 sd->ShutdownWrite(); |
| 113 DartUtils::PostInt32(sd->port(), 1 << kCloseEvent); |
| 106 } | 114 } |
| 107 } | 115 } |
| 108 } | 116 } |
| 109 | 117 |
| 110 | 118 |
| 111 EventHandlerImplementation::EventHandlerImplementation() | 119 EventHandlerImplementation::EventHandlerImplementation() |
| 112 : socket_map_(&HashMap::SamePointerValue, 16) { | 120 : socket_map_(&HashMap::SamePointerValue, 16) { |
| 113 intptr_t result; | 121 intptr_t result; |
| 114 result = TEMP_FAILURE_RETRY(pipe(interrupt_fds_)); | 122 result = TEMP_FAILURE_RETRY(pipe(interrupt_fds_)); |
| 115 if (result != 0) { | 123 if (result != 0) { |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 return reinterpret_cast<void*>(fd + 1); | 427 return reinterpret_cast<void*>(fd + 1); |
| 420 } | 428 } |
| 421 | 429 |
| 422 | 430 |
| 423 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { | 431 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { |
| 424 // The hashmap does not support keys with value 0. | 432 // The hashmap does not support keys with value 0. |
| 425 return dart::Utils::WordHash(fd + 1); | 433 return dart::Utils::WordHash(fd + 1); |
| 426 } | 434 } |
| 427 | 435 |
| 428 #endif // defined(TARGET_OS_MACOS) | 436 #endif // defined(TARGET_OS_MACOS) |
| OLD | NEW |