| 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 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 } | 307 } |
| 308 | 308 |
| 309 // On pipes EPOLLHUP is reported without EPOLLIN when there is no | 309 // On pipes EPOLLHUP is reported without EPOLLIN when there is no |
| 310 // more data to read. | 310 // more data to read. |
| 311 if (sd->IsPipe()) { | 311 if (sd->IsPipe()) { |
| 312 if (((events & EPOLLIN) == 0) && | 312 if (((events & EPOLLIN) == 0) && |
| 313 ((events & EPOLLHUP) != 0)) { | 313 ((events & EPOLLHUP) != 0)) { |
| 314 event_mask = (1 << kCloseEvent); | 314 event_mask = (1 << kCloseEvent); |
| 315 sd->MarkClosedRead(); | 315 sd->MarkClosedRead(); |
| 316 } | 316 } |
| 317 } else { |
| 318 // Assert we never get an EPOLLHUP on a non-pipe file-descriptor. |
| 319 ASSERT(events != EPOLLHUP); |
| 317 } | 320 } |
| 318 | 321 |
| 319 if ((events & EPOLLOUT) != 0) { | 322 if ((events & EPOLLOUT) != 0) { |
| 320 if ((events & EPOLLERR) != 0) { | 323 if ((events & EPOLLERR) != 0) { |
| 321 event_mask = (1 << kErrorEvent); | 324 event_mask = (1 << kErrorEvent); |
| 322 sd->MarkClosedWrite(); | 325 sd->MarkClosedWrite(); |
| 323 } else { | 326 } else { |
| 324 event_mask |= (1 << kOutEvent); | 327 event_mask |= (1 << kOutEvent); |
| 325 } | 328 } |
| 326 } | 329 } |
| 330 |
| 331 if (events == (EPOLLHUP | EPOLLERR)) { |
| 332 event_mask = (1 << kErrorEvent); |
| 333 sd->MarkClosedWrite(); |
| 334 sd->MarkClosedRead(); |
| 335 } |
| 327 } | 336 } |
| 328 | 337 |
| 329 return event_mask; | 338 return event_mask; |
| 330 } | 339 } |
| 331 | 340 |
| 332 | 341 |
| 333 void EventHandlerImplementation::HandleEvents(struct epoll_event* events, | 342 void EventHandlerImplementation::HandleEvents(struct epoll_event* events, |
| 334 int size) { | 343 int size) { |
| 335 for (int i = 0; i < size; i++) { | 344 for (int i = 0; i < size; i++) { |
| 336 if (events[i].data.ptr != NULL) { | 345 if (events[i].data.ptr != NULL) { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 425 return reinterpret_cast<void*>(fd + 1); | 434 return reinterpret_cast<void*>(fd + 1); |
| 426 } | 435 } |
| 427 | 436 |
| 428 | 437 |
| 429 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { | 438 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { |
| 430 // The hashmap does not support keys with value 0. | 439 // The hashmap does not support keys with value 0. |
| 431 return dart::Utils::WordHash(fd + 1); | 440 return dart::Utils::WordHash(fd + 1); |
| 432 } | 441 } |
| 433 | 442 |
| 434 #endif // defined(TARGET_OS_LINUX) | 443 #endif // defined(TARGET_OS_LINUX) |
| OLD | NEW |