| 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_ANDROID) | 6 #if defined(TARGET_OS_ANDROID) |
| 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 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 | 334 |
| 335 void EventHandlerImplementation::HandleEvents(struct epoll_event* events, | 335 void EventHandlerImplementation::HandleEvents(struct epoll_event* events, |
| 336 int size) { | 336 int size) { |
| 337 bool interrupt_seen = false; | 337 bool interrupt_seen = false; |
| 338 for (int i = 0; i < size; i++) { | 338 for (int i = 0; i < size; i++) { |
| 339 if (events[i].data.ptr == NULL) { | 339 if (events[i].data.ptr == NULL) { |
| 340 interrupt_seen = true; | 340 interrupt_seen = true; |
| 341 } else { | 341 } else { |
| 342 SocketData* sd = reinterpret_cast<SocketData*>(events[i].data.ptr); | 342 SocketData* sd = reinterpret_cast<SocketData*>(events[i].data.ptr); |
| 343 intptr_t event_mask = GetPollEvents(events[i].events, sd); | 343 intptr_t event_mask = GetPollEvents(events[i].events, sd); |
| 344 if (event_mask != 0) { | 344 if (event_mask == 0) { |
| 345 // Event not handled, re-add to epoll. |
| 346 UpdateEpollInstance(epoll_fd_, sd); |
| 347 } else { |
| 345 Dart_Port port = sd->port(); | 348 Dart_Port port = sd->port(); |
| 346 ASSERT(port != 0); | 349 ASSERT(port != 0); |
| 347 DartUtils::PostInt32(port, event_mask); | 350 DartUtils::PostInt32(port, event_mask); |
| 348 } | 351 } |
| 349 } | 352 } |
| 350 } | 353 } |
| 351 if (interrupt_seen) { | 354 if (interrupt_seen) { |
| 352 // Handle after socket events, so we avoid closing a socket before we handle | 355 // Handle after socket events, so we avoid closing a socket before we handle |
| 353 // the current events. | 356 // the current events. |
| 354 HandleInterruptFd(); | 357 HandleInterruptFd(); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 | 438 |
| 436 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { | 439 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { |
| 437 // The hashmap does not support keys with value 0. | 440 // The hashmap does not support keys with value 0. |
| 438 return dart::Utils::WordHash(fd + 1); | 441 return dart::Utils::WordHash(fd + 1); |
| 439 } | 442 } |
| 440 | 443 |
| 441 } // namespace bin | 444 } // namespace bin |
| 442 } // namespace dart | 445 } // namespace dart |
| 443 | 446 |
| 444 #endif // defined(TARGET_OS_ANDROID) | 447 #endif // defined(TARGET_OS_ANDROID) |
| OLD | NEW |