| 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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 struct kevent event; | 128 struct kevent event; |
| 129 EV_SET(&event, interrupt_fds_[0], EVFILT_READ, EV_ADD, 0, 0, NULL); | 129 EV_SET(&event, interrupt_fds_[0], EVFILT_READ, EV_ADD, 0, 0, NULL); |
| 130 int status = TEMP_FAILURE_RETRY(kevent(kqueue_fd_, &event, 1, NULL, 0, NULL)); | 130 int status = TEMP_FAILURE_RETRY(kevent(kqueue_fd_, &event, 1, NULL, 0, NULL)); |
| 131 if (status == -1) { | 131 if (status == -1) { |
| 132 FATAL1("Failed adding interrupt fd to kqueue: %s\n", strerror(errno)); | 132 FATAL1("Failed adding interrupt fd to kqueue: %s\n", strerror(errno)); |
| 133 } | 133 } |
| 134 } | 134 } |
| 135 | 135 |
| 136 | 136 |
| 137 EventHandlerImplementation::~EventHandlerImplementation() { | 137 EventHandlerImplementation::~EventHandlerImplementation() { |
| 138 TEMP_FAILURE_RETRY(close(interrupt_fds_[0])); | 138 VOID_TEMP_FAILURE_RETRY(close(interrupt_fds_[0])); |
| 139 TEMP_FAILURE_RETRY(close(interrupt_fds_[1])); | 139 VOID_TEMP_FAILURE_RETRY(close(interrupt_fds_[1])); |
| 140 } | 140 } |
| 141 | 141 |
| 142 | 142 |
| 143 SocketData* EventHandlerImplementation::GetSocketData(intptr_t fd) { | 143 SocketData* EventHandlerImplementation::GetSocketData(intptr_t fd) { |
| 144 ASSERT(fd >= 0); | 144 ASSERT(fd >= 0); |
| 145 HashMap::Entry* entry = socket_map_.Lookup( | 145 HashMap::Entry* entry = socket_map_.Lookup( |
| 146 GetHashmapKeyFromFd(fd), GetHashmapHashFromFd(fd), true); | 146 GetHashmapKeyFromFd(fd), GetHashmapHashFromFd(fd), true); |
| 147 ASSERT(entry != NULL); | 147 ASSERT(entry != NULL); |
| 148 SocketData* sd = reinterpret_cast<SocketData*>(entry->value); | 148 SocketData* sd = reinterpret_cast<SocketData*>(entry->value); |
| 149 if (sd == NULL) { | 149 if (sd == NULL) { |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 void* EventHandlerImplementation::GetHashmapKeyFromFd(intptr_t fd) { | 408 void* EventHandlerImplementation::GetHashmapKeyFromFd(intptr_t fd) { |
| 409 // The hashmap does not support keys with value 0. | 409 // The hashmap does not support keys with value 0. |
| 410 return reinterpret_cast<void*>(fd + 1); | 410 return reinterpret_cast<void*>(fd + 1); |
| 411 } | 411 } |
| 412 | 412 |
| 413 | 413 |
| 414 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { | 414 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { |
| 415 // The hashmap does not support keys with value 0. | 415 // The hashmap does not support keys with value 0. |
| 416 return dart::Utils::WordHash(fd + 1); | 416 return dart::Utils::WordHash(fd + 1); |
| 417 } | 417 } |
| OLD | NEW |