| 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 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 sd->Close(); | 212 sd->Close(); |
| 213 socket_map_.Remove(GetHashmapKeyFromFd(fd), GetHashmapHashFromFd(fd)); | 213 socket_map_.Remove(GetHashmapKeyFromFd(fd), GetHashmapHashFromFd(fd)); |
| 214 delete sd; | 214 delete sd; |
| 215 } | 215 } |
| 216 DartUtils::PostInt32(msg[i].dart_port, 1 << kDestroyedEvent); | 216 DartUtils::PostInt32(msg[i].dart_port, 1 << kDestroyedEvent); |
| 217 } else if (IS_COMMAND(msg[i].data, kReturnTokenCommand)) { | 217 } else if (IS_COMMAND(msg[i].data, kReturnTokenCommand)) { |
| 218 int count = TOKEN_COUNT(msg[i].data); | 218 int count = TOKEN_COUNT(msg[i].data); |
| 219 if (sd->ReturnToken(msg[i].dart_port, count)) { | 219 if (sd->ReturnToken(msg[i].dart_port, count)) { |
| 220 AddToEpollInstance(epoll_fd_, sd); | 220 AddToEpollInstance(epoll_fd_, sd); |
| 221 } | 221 } |
| 222 } else { | 222 } else if (IS_COMMAND(msg[i].data, kSetEventMaskCommand)) { |
| 223 ASSERT_NO_COMMAND(msg[i].data); | 223 // `events` can only have kInEvent/kOutEvent flags set. |
| 224 intptr_t events = msg[i].data & EVENT_MASK; |
| 225 ASSERT(0 == (events & ~(1 << kInEvent) & ~(1 << kOutEvent))); |
| 226 |
| 224 // Setup events to wait for. | 227 // Setup events to wait for. |
| 225 if (sd->AddPort(msg[i].dart_port)) { | 228 if (sd->AddPort(msg[i].dart_port)) { |
| 226 sd->SetMask(msg[i].data); | 229 sd->SetMask(events); |
| 227 AddToEpollInstance(epoll_fd_, sd); | 230 AddToEpollInstance(epoll_fd_, sd); |
| 228 } | 231 } |
| 232 } else { |
| 233 UNREACHABLE(); |
| 229 } | 234 } |
| 230 } | 235 } |
| 231 } | 236 } |
| 232 } | 237 } |
| 233 | 238 |
| 234 #ifdef DEBUG_POLL | 239 #ifdef DEBUG_POLL |
| 235 static void PrintEventMask(intptr_t fd, intptr_t events) { | 240 static void PrintEventMask(intptr_t fd, intptr_t events) { |
| 236 Log::Print("%d ", fd); | 241 Log::Print("%d ", fd); |
| 237 if ((events & EPOLLIN) != 0) Log::Print("EPOLLIN "); | 242 if ((events & EPOLLIN) != 0) Log::Print("EPOLLIN "); |
| 238 if ((events & EPOLLPRI) != 0) Log::Print("EPOLLPRI "); | 243 if ((events & EPOLLPRI) != 0) Log::Print("EPOLLPRI "); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 | 362 |
| 358 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { | 363 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { |
| 359 // The hashmap does not support keys with value 0. | 364 // The hashmap does not support keys with value 0. |
| 360 return dart::Utils::WordHash(fd + 1); | 365 return dart::Utils::WordHash(fd + 1); |
| 361 } | 366 } |
| 362 | 367 |
| 363 } // namespace bin | 368 } // namespace bin |
| 364 } // namespace dart | 369 } // namespace dart |
| 365 | 370 |
| 366 #endif // defined(TARGET_OS_LINUX) | 371 #endif // defined(TARGET_OS_LINUX) |
| OLD | NEW |