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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 UpdateKqueue(kqueue_fd_, sd); | 220 UpdateKqueue(kqueue_fd_, sd); |
221 } else if ((msg.data & (1 << kCloseCommand)) != 0) { | 221 } else if ((msg.data & (1 << kCloseCommand)) != 0) { |
222 ASSERT(msg.data == (1 << kCloseCommand)); | 222 ASSERT(msg.data == (1 << kCloseCommand)); |
223 // Close the socket and free system resources. | 223 // Close the socket and free system resources. |
224 RemoveFromKqueue(kqueue_fd_, sd); | 224 RemoveFromKqueue(kqueue_fd_, sd); |
225 intptr_t fd = sd->fd(); | 225 intptr_t fd = sd->fd(); |
226 sd->Close(); | 226 sd->Close(); |
227 socket_map_.Remove(GetHashmapKeyFromFd(fd), GetHashmapHashFromFd(fd)); | 227 socket_map_.Remove(GetHashmapKeyFromFd(fd), GetHashmapHashFromFd(fd)); |
228 delete sd; | 228 delete sd; |
229 } else { | 229 } else { |
230 // Setup events to wait for. | 230 if ((msg.data & (1 << kInEvent)) != 0 && sd->IsClosedRead()) { |
231 sd->SetPortAndMask(msg.dart_port, msg.data); | 231 DartUtils::PostInt32(msg.dart_port, 1 << kCloseEvent); |
232 UpdateKqueue(kqueue_fd_, sd); | 232 } else { |
| 233 // Setup events to wait for. |
| 234 sd->SetPortAndMask(msg.dart_port, msg.data); |
| 235 UpdateKqueue(kqueue_fd_, sd); |
| 236 } |
233 } | 237 } |
234 } | 238 } |
235 } | 239 } |
236 } | 240 } |
237 | 241 |
238 #ifdef DEBUG_KQUEUE | 242 #ifdef DEBUG_KQUEUE |
239 static void PrintEventMask(intptr_t fd, struct kevent* event) { | 243 static void PrintEventMask(intptr_t fd, struct kevent* event) { |
240 Log::Print("%d ", static_cast<int>(fd)); | 244 Log::Print("%d ", static_cast<int>(fd)); |
241 if (event->filter == EVFILT_READ) Log::Print("EVFILT_READ "); | 245 if (event->filter == EVFILT_READ) Log::Print("EVFILT_READ "); |
242 if (event->filter == EVFILT_WRITE) Log::Print("EVFILT_WRITE "); | 246 if (event->filter == EVFILT_WRITE) Log::Print("EVFILT_WRITE "); |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 return reinterpret_cast<void*>(fd + 1); | 417 return reinterpret_cast<void*>(fd + 1); |
414 } | 418 } |
415 | 419 |
416 | 420 |
417 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { | 421 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { |
418 // The hashmap does not support keys with value 0. | 422 // The hashmap does not support keys with value 0. |
419 return dart::Utils::WordHash(fd + 1); | 423 return dart::Utils::WordHash(fd + 1); |
420 } | 424 } |
421 | 425 |
422 #endif // defined(TARGET_OS_MACOS) | 426 #endif // defined(TARGET_OS_MACOS) |
OLD | NEW |