| 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_LINUX) | 6 #if defined(TARGET_OS_LINUX) |
| 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 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 // Close the socket for writing. | 217 // Close the socket for writing. |
| 218 sd->ShutdownWrite(); | 218 sd->ShutdownWrite(); |
| 219 UpdateEpollInstance(epoll_fd_, sd); | 219 UpdateEpollInstance(epoll_fd_, sd); |
| 220 } else if ((msg.data & (1 << kCloseCommand)) != 0) { | 220 } else if ((msg.data & (1 << kCloseCommand)) != 0) { |
| 221 ASSERT(msg.data == (1 << kCloseCommand)); | 221 ASSERT(msg.data == (1 << kCloseCommand)); |
| 222 // Close the socket and free system resources and move on to | 222 // Close the socket and free system resources and move on to |
| 223 // next message. | 223 // next message. |
| 224 RemoveFromEpollInstance(epoll_fd_, sd); | 224 RemoveFromEpollInstance(epoll_fd_, sd); |
| 225 intptr_t fd = sd->fd(); | 225 intptr_t fd = sd->fd(); |
| 226 sd->Close(); | 226 sd->Close(); |
| 227 // If stdout, reuse fd and direct to /dev/null. |
| 228 if (fd == fileno(stdout)) USE(fopen("/dev/null", "r")); |
| 227 socket_map_.Remove(GetHashmapKeyFromFd(fd), GetHashmapHashFromFd(fd)); | 229 socket_map_.Remove(GetHashmapKeyFromFd(fd), GetHashmapHashFromFd(fd)); |
| 228 delete sd; | 230 delete sd; |
| 229 } else { | 231 } else { |
| 230 if ((msg.data & (1 << kInEvent)) != 0 && sd->IsClosedRead()) { | 232 if ((msg.data & (1 << kInEvent)) != 0 && sd->IsClosedRead()) { |
| 231 DartUtils::PostInt32(msg.dart_port, 1 << kCloseEvent); | 233 DartUtils::PostInt32(msg.dart_port, 1 << kCloseEvent); |
| 232 } else { | 234 } else { |
| 233 // Setup events to wait for. | 235 // Setup events to wait for. |
| 234 sd->SetPortAndMask(msg.dart_port, msg.data); | 236 sd->SetPortAndMask(msg.dart_port, msg.data); |
| 235 UpdateEpollInstance(epoll_fd_, sd); | 237 UpdateEpollInstance(epoll_fd_, sd); |
| 236 } | 238 } |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 | 435 |
| 434 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { | 436 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { |
| 435 // The hashmap does not support keys with value 0. | 437 // The hashmap does not support keys with value 0. |
| 436 return dart::Utils::WordHash(fd + 1); | 438 return dart::Utils::WordHash(fd + 1); |
| 437 } | 439 } |
| 438 | 440 |
| 439 } // namespace bin | 441 } // namespace bin |
| 440 } // namespace dart | 442 } // namespace dart |
| 441 | 443 |
| 442 #endif // defined(TARGET_OS_LINUX) | 444 #endif // defined(TARGET_OS_LINUX) |
| OLD | NEW |