| 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 "bin/eventhandler.h" | 5 #include "bin/eventhandler.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 #include <pthread.h> | 8 #include <pthread.h> |
| 9 #include <stdio.h> | 9 #include <stdio.h> |
| 10 #include <string.h> | 10 #include <string.h> |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 if (result != kInterruptMessageSize) { | 161 if (result != kInterruptMessageSize) { |
| 162 if (result == -1) { | 162 if (result == -1) { |
| 163 perror("Interrupt message failure:"); | 163 perror("Interrupt message failure:"); |
| 164 } | 164 } |
| 165 FATAL1("Interrupt message failure. Wrote %d bytes.", result); | 165 FATAL1("Interrupt message failure. Wrote %d bytes.", result); |
| 166 } | 166 } |
| 167 } | 167 } |
| 168 | 168 |
| 169 | 169 |
| 170 bool EventHandlerImplementation::GetInterruptMessage(InterruptMessage* msg) { | 170 bool EventHandlerImplementation::GetInterruptMessage(InterruptMessage* msg) { |
| 171 char* dst = reinterpret_cast<char*>(msg); |
| 171 int total_read = 0; | 172 int total_read = 0; |
| 172 int bytes_read = | 173 int bytes_read = |
| 173 TEMP_FAILURE_RETRY(read(interrupt_fds_[0], msg, kInterruptMessageSize)); | 174 TEMP_FAILURE_RETRY(read(interrupt_fds_[0], dst, kInterruptMessageSize)); |
| 174 if (bytes_read < 0) { | 175 if (bytes_read < 0) { |
| 175 return false; | 176 return false; |
| 176 } | 177 } |
| 177 total_read = bytes_read; | 178 total_read = bytes_read; |
| 178 while (total_read < kInterruptMessageSize) { | 179 while (total_read < kInterruptMessageSize) { |
| 179 bytes_read = TEMP_FAILURE_RETRY(read(interrupt_fds_[0], | 180 bytes_read = TEMP_FAILURE_RETRY(read(interrupt_fds_[0], |
| 180 msg + total_read, | 181 dst + total_read, |
| 181 kInterruptMessageSize - total_read)); | 182 kInterruptMessageSize - total_read)); |
| 182 if (bytes_read > 0) { | 183 if (bytes_read > 0) { |
| 183 total_read = total_read + bytes_read; | 184 total_read = total_read + bytes_read; |
| 184 } | 185 } |
| 185 } | 186 } |
| 186 return (total_read == kInterruptMessageSize) ? true : false; | 187 return (total_read == kInterruptMessageSize) ? true : false; |
| 187 } | 188 } |
| 188 | 189 |
| 189 void EventHandlerImplementation::HandleInterruptFd() { | 190 void EventHandlerImplementation::HandleInterruptFd() { |
| 190 InterruptMessage msg; | 191 InterruptMessage msg; |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 410 void* EventHandlerImplementation::GetHashmapKeyFromFd(intptr_t fd) { | 411 void* EventHandlerImplementation::GetHashmapKeyFromFd(intptr_t fd) { |
| 411 // The hashmap does not support keys with value 0. | 412 // The hashmap does not support keys with value 0. |
| 412 return reinterpret_cast<void*>(fd + 1); | 413 return reinterpret_cast<void*>(fd + 1); |
| 413 } | 414 } |
| 414 | 415 |
| 415 | 416 |
| 416 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { | 417 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { |
| 417 // The hashmap does not support keys with value 0. | 418 // The hashmap does not support keys with value 0. |
| 418 return dart::Utils::WordHash(fd + 1); | 419 return dart::Utils::WordHash(fd + 1); |
| 419 } | 420 } |
| OLD | NEW |