| 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 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 if ((events[i].flags & EV_ERROR) != 0) { | 332 if ((events[i].flags & EV_ERROR) != 0) { |
| 333 const int kBufferSize = 1024; | 333 const int kBufferSize = 1024; |
| 334 char error_message[kBufferSize]; | 334 char error_message[kBufferSize]; |
| 335 strerror_r(events[i].data, error_message, kBufferSize); | 335 strerror_r(events[i].data, error_message, kBufferSize); |
| 336 FATAL1("kevent failed %s\n", error_message); | 336 FATAL1("kevent failed %s\n", error_message); |
| 337 } | 337 } |
| 338 if (events[i].udata == NULL) { | 338 if (events[i].udata == NULL) { |
| 339 interrupt_seen = true; | 339 interrupt_seen = true; |
| 340 } else { | 340 } else { |
| 341 SocketData* sd = reinterpret_cast<SocketData*>(events[i].udata); | 341 SocketData* sd = reinterpret_cast<SocketData*>(events[i].udata); |
| 342 RemoveFromKqueue(kqueue_fd_, sd); | |
| 343 intptr_t event_mask = GetEvents(events + i, sd); | 342 intptr_t event_mask = GetEvents(events + i, sd); |
| 344 if (event_mask != 0) { | 343 if (event_mask != 0) { |
| 344 // Unregister events for the file descriptor. Events will be |
| 345 // registered again when the current event has been handled in |
| 346 // Dart code. |
| 347 RemoveFromKqueue(kqueue_fd_, sd); |
| 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 | 450 |
| 448 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { | 451 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { |
| 449 // The hashmap does not support keys with value 0. | 452 // The hashmap does not support keys with value 0. |
| 450 return dart::Utils::WordHash(fd + 1); | 453 return dart::Utils::WordHash(fd + 1); |
| 451 } | 454 } |
| 452 | 455 |
| 453 } // namespace bin | 456 } // namespace bin |
| 454 } // namespace dart | 457 } // namespace dart |
| 455 | 458 |
| 456 #endif // defined(TARGET_OS_MACOS) | 459 #endif // defined(TARGET_OS_MACOS) |
| OLD | NEW |