| 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 <errno.h> | 5 #include <errno.h> |
| 6 #include <poll.h> | 6 #include <poll.h> |
| 7 #include <pthread.h> | 7 #include <pthread.h> |
| 8 #include <stdio.h> | 8 #include <stdio.h> |
| 9 #include <string.h> | 9 #include <string.h> |
| 10 #include <sys/time.h> | 10 #include <sys/time.h> |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 void EventHandlerImplementation::WakeupHandler(intptr_t id, | 88 void EventHandlerImplementation::WakeupHandler(intptr_t id, |
| 89 Dart_Port dart_port, | 89 Dart_Port dart_port, |
| 90 int64_t data) { | 90 int64_t data) { |
| 91 InterruptMessage msg; | 91 InterruptMessage msg; |
| 92 msg.id = id; | 92 msg.id = id; |
| 93 msg.dart_port = dart_port; | 93 msg.dart_port = dart_port; |
| 94 msg.data = data; | 94 msg.data = data; |
| 95 intptr_t result = | 95 intptr_t result = |
| 96 FDUtils::WriteToBlocking(interrupt_fds_[1], &msg, kInterruptMessageSize); | 96 FDUtils::WriteToBlocking(interrupt_fds_[1], &msg, kInterruptMessageSize); |
| 97 if (result != kInterruptMessageSize) { | 97 if (result != kInterruptMessageSize) { |
| 98 FATAL("Interrupt message failure"); | 98 if (result == -1) { |
| 99 perror("Interrupt message failure:"); |
| 100 } |
| 101 FATAL1("Interrupt message failure. Wrote %d bytes.", result); |
| 99 } | 102 } |
| 100 } | 103 } |
| 101 | 104 |
| 102 | 105 |
| 103 struct pollfd* EventHandlerImplementation::GetPollFds(intptr_t* pollfds_size) { | 106 struct pollfd* EventHandlerImplementation::GetPollFds(intptr_t* pollfds_size) { |
| 104 struct pollfd* pollfds; | 107 struct pollfd* pollfds; |
| 105 | 108 |
| 106 // Calculate the number of file descriptors to poll on. | 109 // Calculate the number of file descriptors to poll on. |
| 107 intptr_t numPollfds = 1; | 110 intptr_t numPollfds = 1; |
| 108 for (HashMap::Entry* entry = socket_map_.Start(); | 111 for (HashMap::Entry* entry = socket_map_.Start(); |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 void* EventHandlerImplementation::GetHashmapKeyFromFd(intptr_t fd) { | 383 void* EventHandlerImplementation::GetHashmapKeyFromFd(intptr_t fd) { |
| 381 // The hashmap does not support keys with value 0. | 384 // The hashmap does not support keys with value 0. |
| 382 return reinterpret_cast<void*>(fd + 1); | 385 return reinterpret_cast<void*>(fd + 1); |
| 383 } | 386 } |
| 384 | 387 |
| 385 | 388 |
| 386 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { | 389 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { |
| 387 // The hashmap does not support keys with value 0. | 390 // The hashmap does not support keys with value 0. |
| 388 return dart::Utils::WordHash(fd + 1); | 391 return dart::Utils::WordHash(fd + 1); |
| 389 } | 392 } |
| OLD | NEW |