| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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_FUCHSIA) | 8 #if defined(TARGET_OS_FUCHSIA) |
| 9 | 9 |
| 10 #include "bin/eventhandler.h" | 10 #include "bin/eventhandler.h" |
| (...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 void EventHandlerImplementation::Poll(uword args) { | 442 void EventHandlerImplementation::Poll(uword args) { |
| 443 static const intptr_t kMaxEvents = 16; | 443 static const intptr_t kMaxEvents = 16; |
| 444 struct epoll_event events[kMaxEvents]; | 444 struct epoll_event events[kMaxEvents]; |
| 445 EventHandler* handler = reinterpret_cast<EventHandler*>(args); | 445 EventHandler* handler = reinterpret_cast<EventHandler*>(args); |
| 446 EventHandlerImplementation* handler_impl = &handler->delegate_; | 446 EventHandlerImplementation* handler_impl = &handler->delegate_; |
| 447 ASSERT(handler_impl != NULL); | 447 ASSERT(handler_impl != NULL); |
| 448 | 448 |
| 449 while (!handler_impl->shutdown_) { | 449 while (!handler_impl->shutdown_) { |
| 450 int64_t millis = handler_impl->GetTimeout(); | 450 int64_t millis = handler_impl->GetTimeout(); |
| 451 ASSERT((millis == kInfinityTimeout) || (millis >= 0)); | 451 ASSERT((millis == kInfinityTimeout) || (millis >= 0)); |
| 452 // TODO(US-109): When the epoll implementation is properly edge-triggered, |
| 453 // remove this sleep, which prevents the message queue from being |
| 454 // overwhelmed and leading to memory exhaustion. |
| 455 usleep(5000); |
| 452 LOG_INFO("epoll_wait(millis = %ld)\n", millis); | 456 LOG_INFO("epoll_wait(millis = %ld)\n", millis); |
| 453 intptr_t result = NO_RETRY_EXPECTED( | 457 intptr_t result = NO_RETRY_EXPECTED( |
| 454 epoll_wait(handler_impl->epoll_fd_, events, kMaxEvents, millis)); | 458 epoll_wait(handler_impl->epoll_fd_, events, kMaxEvents, millis)); |
| 455 ASSERT(EAGAIN == EWOULDBLOCK); | 459 ASSERT(EAGAIN == EWOULDBLOCK); |
| 456 LOG_INFO("epoll_wait(millis = %ld) -> %ld\n", millis, result); | 460 LOG_INFO("epoll_wait(millis = %ld) -> %ld\n", millis, result); |
| 457 if (result < 0) { | 461 if (result < 0) { |
| 458 if (errno != EWOULDBLOCK) { | 462 if (errno != EWOULDBLOCK) { |
| 459 perror("Poll failed"); | 463 perror("Poll failed"); |
| 460 } | 464 } |
| 461 } else { | 465 } else { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 // The hashmap does not support keys with value 0. | 501 // The hashmap does not support keys with value 0. |
| 498 return dart::Utils::WordHash(fd + 1); | 502 return dart::Utils::WordHash(fd + 1); |
| 499 } | 503 } |
| 500 | 504 |
| 501 } // namespace bin | 505 } // namespace bin |
| 502 } // namespace dart | 506 } // namespace dart |
| 503 | 507 |
| 504 #endif // defined(TARGET_OS_FUCHSIA) | 508 #endif // defined(TARGET_OS_FUCHSIA) |
| 505 | 509 |
| 506 #endif // !defined(DART_IO_DISABLED) | 510 #endif // !defined(DART_IO_DISABLED) |
| OLD | NEW |