| 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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 it.it_value.tv_nsec = (millis % 1000) * 1000000; | 193 it.it_value.tv_nsec = (millis % 1000) * 1000000; |
| 194 } | 194 } |
| 195 VOID_NO_RETRY_EXPECTED( | 195 VOID_NO_RETRY_EXPECTED( |
| 196 timerfd_settime(timer_fd_, TFD_TIMER_ABSTIME, &it, NULL)); | 196 timerfd_settime(timer_fd_, TFD_TIMER_ABSTIME, &it, NULL)); |
| 197 } else if (msg[i].id == kShutdownId) { | 197 } else if (msg[i].id == kShutdownId) { |
| 198 shutdown_ = true; | 198 shutdown_ = true; |
| 199 } else { | 199 } else { |
| 200 SocketData* sd = GetSocketData( | 200 SocketData* sd = GetSocketData( |
| 201 msg[i].id, (msg[i].data & (1 << kListeningSocket)) != 0); | 201 msg[i].id, (msg[i].data & (1 << kListeningSocket)) != 0); |
| 202 if ((msg[i].data & (1 << kShutdownReadCommand)) != 0) { | 202 if ((msg[i].data & (1 << kShutdownReadCommand)) != 0) { |
| 203 ASSERT(msg[i].data == (1 << kShutdownReadCommand)); | 203 ASSERT(COMMAND_MASK(msg[i].data) == (1 << kShutdownReadCommand)); |
| 204 ASSERT(!sd->IsListeningSocket()); | 204 ASSERT(!sd->IsListeningSocket()); |
| 205 // Close the socket for reading. | 205 // Close the socket for reading. |
| 206 VOID_NO_RETRY_EXPECTED(shutdown(sd->fd(), SHUT_RD)); | 206 VOID_NO_RETRY_EXPECTED(shutdown(sd->fd(), SHUT_RD)); |
| 207 } else if ((msg[i].data & (1 << kShutdownWriteCommand)) != 0) { | 207 } else if ((msg[i].data & (1 << kShutdownWriteCommand)) != 0) { |
| 208 ASSERT(msg[i].data == (1 << kShutdownWriteCommand)); | 208 ASSERT(COMMAND_MASK(msg[i].data) == (1 << kShutdownWriteCommand)); |
| 209 ASSERT(!sd->IsListeningSocket()); | 209 ASSERT(!sd->IsListeningSocket()); |
| 210 // Close the socket for writing. | 210 // Close the socket for writing. |
| 211 VOID_NO_RETRY_EXPECTED(shutdown(sd->fd(), SHUT_WR)); | 211 VOID_NO_RETRY_EXPECTED(shutdown(sd->fd(), SHUT_WR)); |
| 212 } else if ((msg[i].data & (1 << kCloseCommand)) != 0) { | 212 } else if ((msg[i].data & (1 << kCloseCommand)) != 0) { |
| 213 ASSERT(msg[i].data == (1 << kCloseCommand)); | 213 ASSERT(COMMAND_MASK(msg[i].data) == (1 << kCloseCommand)); |
| 214 // Close the socket and free system resources and move on to | 214 // Close the socket and free system resources and move on to |
| 215 // next message. | 215 // next message. |
| 216 if (sd->RemovePort(msg[i].dart_port)) { | 216 if (sd->RemovePort(msg[i].dart_port)) { |
| 217 RemoveFromEpollInstance(epoll_fd_, sd); | 217 RemoveFromEpollInstance(epoll_fd_, sd); |
| 218 intptr_t fd = sd->fd(); | 218 intptr_t fd = sd->fd(); |
| 219 sd->Close(); | 219 sd->Close(); |
| 220 socket_map_.Remove(GetHashmapKeyFromFd(fd), GetHashmapHashFromFd(fd)); | 220 socket_map_.Remove(GetHashmapKeyFromFd(fd), GetHashmapHashFromFd(fd)); |
| 221 delete sd; | 221 delete sd; |
| 222 } | 222 } |
| 223 DartUtils::PostInt32(msg[i].dart_port, 1 << kDestroyedEvent); | 223 DartUtils::PostInt32(msg[i].dart_port, 1 << kDestroyedEvent); |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 | 362 |
| 363 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { | 363 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { |
| 364 // The hashmap does not support keys with value 0. | 364 // The hashmap does not support keys with value 0. |
| 365 return dart::Utils::WordHash(fd + 1); | 365 return dart::Utils::WordHash(fd + 1); |
| 366 } | 366 } |
| 367 | 367 |
| 368 } // namespace bin | 368 } // namespace bin |
| 369 } // namespace dart | 369 } // namespace dart |
| 370 | 370 |
| 371 #endif // defined(TARGET_OS_LINUX) | 371 #endif // defined(TARGET_OS_LINUX) |
| OLD | NEW |