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 #include "bin/eventhandler_linux.h" | 9 #include "bin/eventhandler_linux.h" |
10 | 10 |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 } | 135 } |
136 | 136 |
137 | 137 |
138 void EventHandlerImplementation::UpdateEpollInstance(intptr_t old_mask, | 138 void EventHandlerImplementation::UpdateEpollInstance(intptr_t old_mask, |
139 DescriptorInfo *di) { | 139 DescriptorInfo *di) { |
140 intptr_t new_mask = di->Mask(); | 140 intptr_t new_mask = di->Mask(); |
141 if (old_mask != 0 && new_mask == 0) { | 141 if (old_mask != 0 && new_mask == 0) { |
142 RemoveFromEpollInstance(epoll_fd_, di); | 142 RemoveFromEpollInstance(epoll_fd_, di); |
143 } else if (old_mask == 0 && new_mask != 0) { | 143 } else if (old_mask == 0 && new_mask != 0) { |
144 AddToEpollInstance(epoll_fd_, di); | 144 AddToEpollInstance(epoll_fd_, di); |
145 } else if (old_mask != 0 && new_mask != 0) { | 145 } else if (old_mask != 0 && new_mask != 0 && old_mask != new_mask) { |
146 if (di->IsListeningSocket()) { | 146 ASSERT(!di->IsListeningSocket()); |
147 ASSERT(old_mask == new_mask); | 147 RemoveFromEpollInstance(epoll_fd_, di); |
148 } else { | 148 AddToEpollInstance(epoll_fd_, di); |
149 RemoveFromEpollInstance(epoll_fd_, di); | |
150 AddToEpollInstance(epoll_fd_, di); | |
151 } | |
152 } | 149 } |
153 } | 150 } |
154 | 151 |
155 | 152 |
156 DescriptorInfo* EventHandlerImplementation::GetDescriptorInfo( | 153 DescriptorInfo* EventHandlerImplementation::GetDescriptorInfo( |
157 intptr_t fd, bool is_listening) { | 154 intptr_t fd, bool is_listening) { |
158 ASSERT(fd >= 0); | 155 ASSERT(fd >= 0); |
159 HashMap::Entry* entry = socket_map_.Lookup( | 156 HashMap::Entry* entry = socket_map_.Lookup( |
160 GetHashmapKeyFromFd(fd), GetHashmapHashFromFd(fd), true); | 157 GetHashmapKeyFromFd(fd), GetHashmapHashFromFd(fd), true); |
161 ASSERT(entry != NULL); | 158 ASSERT(entry != NULL); |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 | 411 |
415 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { | 412 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { |
416 // The hashmap does not support keys with value 0. | 413 // The hashmap does not support keys with value 0. |
417 return dart::Utils::WordHash(fd + 1); | 414 return dart::Utils::WordHash(fd + 1); |
418 } | 415 } |
419 | 416 |
420 } // namespace bin | 417 } // namespace bin |
421 } // namespace dart | 418 } // namespace dart |
422 | 419 |
423 #endif // defined(TARGET_OS_LINUX) | 420 #endif // defined(TARGET_OS_LINUX) |
OLD | NEW |