| 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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 ASSERT(msg[i].data == (1 << kShutdownWriteCommand)); | 196 ASSERT(msg[i].data == (1 << kShutdownWriteCommand)); |
| 197 // Close the socket for writing. | 197 // Close the socket for writing. |
| 198 sd->ShutdownWrite(); | 198 sd->ShutdownWrite(); |
| 199 UpdateEpollInstance(epoll_fd_, sd); | 199 UpdateEpollInstance(epoll_fd_, sd); |
| 200 } else if ((msg[i].data & (1 << kCloseCommand)) != 0) { | 200 } else if ((msg[i].data & (1 << kCloseCommand)) != 0) { |
| 201 ASSERT(msg[i].data == (1 << kCloseCommand)); | 201 ASSERT(msg[i].data == (1 << kCloseCommand)); |
| 202 // Close the socket and free system resources and move on to | 202 // Close the socket and free system resources and move on to |
| 203 // next message. | 203 // next message. |
| 204 RemoveFromEpollInstance(epoll_fd_, sd); | 204 RemoveFromEpollInstance(epoll_fd_, sd); |
| 205 intptr_t fd = sd->fd(); | 205 intptr_t fd = sd->fd(); |
| 206 if (fd == STDOUT_FILENO) { | 206 sd->Close(); |
| 207 // If stdout, redirect fd to /dev/null. | |
| 208 int null_fd = TEMP_FAILURE_RETRY(open("/dev/null", O_WRONLY)); | |
| 209 ASSERT(null_fd >= 0); | |
| 210 VOID_TEMP_FAILURE_RETRY(dup2(null_fd, STDOUT_FILENO)); | |
| 211 VOID_TEMP_FAILURE_RETRY(close(null_fd)); | |
| 212 } else { | |
| 213 sd->Close(); | |
| 214 } | |
| 215 socket_map_.Remove(GetHashmapKeyFromFd(fd), GetHashmapHashFromFd(fd)); | 207 socket_map_.Remove(GetHashmapKeyFromFd(fd), GetHashmapHashFromFd(fd)); |
| 216 delete sd; | 208 delete sd; |
| 217 DartUtils::PostInt32(msg[i].dart_port, 1 << kDestroyedEvent); | 209 DartUtils::PostInt32(msg[i].dart_port, 1 << kDestroyedEvent); |
| 218 } else { | 210 } else { |
| 219 // Setup events to wait for. | 211 // Setup events to wait for. |
| 220 sd->SetPortAndMask(msg[i].dart_port, msg[i].data); | 212 sd->SetPortAndMask(msg[i].dart_port, msg[i].data); |
| 221 UpdateEpollInstance(epoll_fd_, sd); | 213 UpdateEpollInstance(epoll_fd_, sd); |
| 222 } | 214 } |
| 223 } | 215 } |
| 224 } | 216 } |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 | 427 |
| 436 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { | 428 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { |
| 437 // The hashmap does not support keys with value 0. | 429 // The hashmap does not support keys with value 0. |
| 438 return dart::Utils::WordHash(fd + 1); | 430 return dart::Utils::WordHash(fd + 1); |
| 439 } | 431 } |
| 440 | 432 |
| 441 } // namespace bin | 433 } // namespace bin |
| 442 } // namespace dart | 434 } // namespace dart |
| 443 | 435 |
| 444 #endif // defined(TARGET_OS_ANDROID) | 436 #endif // defined(TARGET_OS_ANDROID) |
| OLD | NEW |