| 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_LINUX) | 6 #if defined(TARGET_OS_LINUX) |
| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 sd->fd(), | 77 sd->fd(), |
| 78 &event)); | 78 &event)); |
| 79 } else { | 79 } else { |
| 80 status = TEMP_FAILURE_RETRY(epoll_ctl(epoll_fd_, | 80 status = TEMP_FAILURE_RETRY(epoll_ctl(epoll_fd_, |
| 81 EPOLL_CTL_ADD, | 81 EPOLL_CTL_ADD, |
| 82 sd->fd(), | 82 sd->fd(), |
| 83 &event)); | 83 &event)); |
| 84 sd->set_tracked_by_epoll(true); | 84 sd->set_tracked_by_epoll(true); |
| 85 } | 85 } |
| 86 if (status == -1) { | 86 if (status == -1) { |
| 87 FATAL1("Failed updating epoll instance: %s", strerror(errno)); | 87 // Epoll does not accept the file descriptor. It could be due to |
| 88 // already closed file descriptor, or unuspported devices, such |
| 89 // as /dev/null. In such case, mark the file descriptor as closed, |
| 90 // so dart will handle it accordingly. |
| 91 sd->set_tracked_by_epoll(false); |
| 92 sd->ShutdownRead(); |
| 93 sd->ShutdownWrite(); |
| 94 DartUtils::PostInt32(sd->port(), 1 << kCloseEvent); |
| 88 } | 95 } |
| 89 } | 96 } |
| 90 } | 97 } |
| 91 | 98 |
| 92 | 99 |
| 93 EventHandlerImplementation::EventHandlerImplementation() | 100 EventHandlerImplementation::EventHandlerImplementation() |
| 94 : socket_map_(&HashMap::SamePointerValue, 16) { | 101 : socket_map_(&HashMap::SamePointerValue, 16) { |
| 95 intptr_t result; | 102 intptr_t result; |
| 96 result = TEMP_FAILURE_RETRY(pipe(interrupt_fds_)); | 103 result = TEMP_FAILURE_RETRY(pipe(interrupt_fds_)); |
| 97 if (result != 0) { | 104 if (result != 0) { |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 return reinterpret_cast<void*>(fd + 1); | 423 return reinterpret_cast<void*>(fd + 1); |
| 417 } | 424 } |
| 418 | 425 |
| 419 | 426 |
| 420 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { | 427 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { |
| 421 // The hashmap does not support keys with value 0. | 428 // The hashmap does not support keys with value 0. |
| 422 return dart::Utils::WordHash(fd + 1); | 429 return dart::Utils::WordHash(fd + 1); |
| 423 } | 430 } |
| 424 | 431 |
| 425 #endif // defined(TARGET_OS_LINUX) | 432 #endif // defined(TARGET_OS_LINUX) |
| OLD | NEW |