| 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 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 ASSERT(msg.data == (1 << kShutdownWriteCommand)); | 229 ASSERT(msg.data == (1 << kShutdownWriteCommand)); |
| 230 // Close the socket for writing. | 230 // Close the socket for writing. |
| 231 sd->ShutdownWrite(); | 231 sd->ShutdownWrite(); |
| 232 UpdateKqueue(kqueue_fd_, sd); | 232 UpdateKqueue(kqueue_fd_, sd); |
| 233 } else if ((msg.data & (1 << kCloseCommand)) != 0) { | 233 } else if ((msg.data & (1 << kCloseCommand)) != 0) { |
| 234 ASSERT(msg.data == (1 << kCloseCommand)); | 234 ASSERT(msg.data == (1 << kCloseCommand)); |
| 235 // Close the socket and free system resources. | 235 // Close the socket and free system resources. |
| 236 RemoveFromKqueue(kqueue_fd_, sd); | 236 RemoveFromKqueue(kqueue_fd_, sd); |
| 237 intptr_t fd = sd->fd(); | 237 intptr_t fd = sd->fd(); |
| 238 sd->Close(); | 238 sd->Close(); |
| 239 // If stdout, reuse fd and direct to /dev/null. |
| 240 if (fd == fileno(stdout)) USE(fopen("/dev/null", "r")); |
| 239 socket_map_.Remove(GetHashmapKeyFromFd(fd), GetHashmapHashFromFd(fd)); | 241 socket_map_.Remove(GetHashmapKeyFromFd(fd), GetHashmapHashFromFd(fd)); |
| 240 delete sd; | 242 delete sd; |
| 241 } else { | 243 } else { |
| 242 if ((msg.data & (1 << kInEvent)) != 0 && sd->IsClosedRead()) { | 244 if ((msg.data & (1 << kInEvent)) != 0 && sd->IsClosedRead()) { |
| 243 DartUtils::PostInt32(msg.dart_port, 1 << kCloseEvent); | 245 DartUtils::PostInt32(msg.dart_port, 1 << kCloseEvent); |
| 244 } else { | 246 } else { |
| 245 // Setup events to wait for. | 247 // Setup events to wait for. |
| 246 sd->SetPortAndMask(msg.dart_port, msg.data); | 248 sd->SetPortAndMask(msg.dart_port, msg.data); |
| 247 UpdateKqueue(kqueue_fd_, sd); | 249 UpdateKqueue(kqueue_fd_, sd); |
| 248 } | 250 } |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 | 439 |
| 438 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { | 440 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { |
| 439 // The hashmap does not support keys with value 0. | 441 // The hashmap does not support keys with value 0. |
| 440 return dart::Utils::WordHash(fd + 1); | 442 return dart::Utils::WordHash(fd + 1); |
| 441 } | 443 } |
| 442 | 444 |
| 443 } // namespace bin | 445 } // namespace bin |
| 444 } // namespace dart | 446 } // namespace dart |
| 445 | 447 |
| 446 #endif // defined(TARGET_OS_MACOS) | 448 #endif // defined(TARGET_OS_MACOS) |
| OLD | NEW |