| Index: runtime/bin/eventhandler_linux.cc
|
| diff --git a/runtime/bin/eventhandler_linux.cc b/runtime/bin/eventhandler_linux.cc
|
| index e15f3dfd6b39da908c9552a7d124fdb07547d7e3..041bbf3697655db2b52d0244dca95ec808733c86 100644
|
| --- a/runtime/bin/eventhandler_linux.cc
|
| +++ b/runtime/bin/eventhandler_linux.cc
|
| @@ -33,6 +33,7 @@ int64_t GetCurrentTimeMilliseconds() {
|
| static const int kInterruptMessageSize = sizeof(InterruptMessage);
|
| static const int kInfinityTimeout = -1;
|
| static const int kTimerId = -1;
|
| +static const int kShutdownId = -2;
|
|
|
|
|
| intptr_t SocketData::GetPollEvents() {
|
| @@ -105,6 +106,7 @@ EventHandlerImplementation::EventHandlerImplementation()
|
| FDUtils::SetNonBlocking(interrupt_fds_[0]);
|
| timeout_ = kInfinityTimeout;
|
| timeout_port_ = 0;
|
| + shutdown_ = false;
|
| // The initial size passed to epoll_create is ignore on newer (>=
|
| // 2.6.8) Linux versions
|
| static const int kEpollInitialSize = 64;
|
| @@ -193,6 +195,8 @@ void EventHandlerImplementation::HandleInterruptFd() {
|
| if (msg.id == kTimerId) {
|
| timeout_ = msg.data;
|
| timeout_port_ = msg.dart_port;
|
| + } else if (msg.id == kShutdownId) {
|
| + shutdown_ = true;
|
| } else {
|
| SocketData* sd = GetSocketData(msg.id);
|
| if ((msg.data & (1 << kShutdownReadCommand)) != 0) {
|
| @@ -373,7 +377,7 @@ void EventHandlerImplementation::Poll(uword args) {
|
| EventHandlerImplementation* handler =
|
| reinterpret_cast<EventHandlerImplementation*>(args);
|
| ASSERT(handler != NULL);
|
| - while (1) {
|
| + while (!handler->shutdown_) {
|
| intptr_t millis = handler->GetTimeout();
|
| intptr_t result = TEMP_FAILURE_RETRY(epoll_wait(handler->epoll_fd_,
|
| events,
|
| @@ -392,7 +396,7 @@ void EventHandlerImplementation::Poll(uword args) {
|
| }
|
|
|
|
|
| -void EventHandlerImplementation::StartEventHandler() {
|
| +void EventHandlerImplementation::Start() {
|
| int result = dart::Thread::Start(&EventHandlerImplementation::Poll,
|
| reinterpret_cast<uword>(this));
|
| if (result != 0) {
|
| @@ -401,6 +405,11 @@ void EventHandlerImplementation::StartEventHandler() {
|
| }
|
|
|
|
|
| +void EventHandlerImplementation::Shutdown() {
|
| + SendData(kShutdownId, 0, 0);
|
| +}
|
| +
|
| +
|
| void EventHandlerImplementation::SendData(intptr_t id,
|
| Dart_Port dart_port,
|
| intptr_t data) {
|
|
|