| 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 | 10 |
| 10 #include <errno.h> // NOLINT | 11 #include <errno.h> // NOLINT |
| 11 #include <pthread.h> // NOLINT | 12 #include <pthread.h> // NOLINT |
| 12 #include <stdio.h> // NOLINT | 13 #include <stdio.h> // NOLINT |
| 13 #include <string.h> // NOLINT | 14 #include <string.h> // NOLINT |
| 14 #include <sys/epoll.h> // NOLINT | 15 #include <sys/epoll.h> // NOLINT |
| 15 #include <sys/stat.h> // NOLINT | 16 #include <sys/stat.h> // NOLINT |
| 16 #include <sys/timerfd.h> // NOLINT | 17 #include <sys/timerfd.h> // NOLINT |
| 17 #include <unistd.h> // NOLINT | 18 #include <unistd.h> // NOLINT |
| 18 #include <fcntl.h> // NOLINT | 19 #include <fcntl.h> // NOLINT |
| 19 | 20 |
| 20 #include "bin/dartutils.h" | 21 #include "bin/dartutils.h" |
| 21 #include "bin/fdutils.h" | 22 #include "bin/fdutils.h" |
| 22 #include "bin/log.h" | 23 #include "bin/log.h" |
| 24 #include "bin/lockers.h" |
| 23 #include "bin/socket.h" | 25 #include "bin/socket.h" |
| 24 #include "bin/thread.h" | 26 #include "bin/thread.h" |
| 25 #include "platform/utils.h" | 27 #include "platform/utils.h" |
| 26 | 28 |
| 27 | 29 |
| 28 namespace dart { | 30 namespace dart { |
| 29 namespace bin { | 31 namespace bin { |
| 30 | 32 |
| 31 | 33 |
| 32 intptr_t SocketData::GetPollEvents() { | 34 intptr_t DescriptorInfo::GetPollEvents() { |
| 33 // Do not ask for EPOLLERR and EPOLLHUP explicitly as they are | 35 // Do not ask for EPOLLERR and EPOLLHUP explicitly as they are |
| 34 // triggered anyway. | 36 // triggered anyway. |
| 35 intptr_t events = 0; | 37 intptr_t events = 0; |
| 36 if ((mask_ & (1 << kInEvent)) != 0) { | 38 if ((Mask() & (1 << kInEvent)) != 0) { |
| 37 events |= EPOLLIN; | 39 events |= EPOLLIN; |
| 38 } | 40 } |
| 39 if ((mask_ & (1 << kOutEvent)) != 0) { | 41 if ((Mask() & (1 << kOutEvent)) != 0) { |
| 40 events |= EPOLLOUT; | 42 events |= EPOLLOUT; |
| 41 } | 43 } |
| 42 return events; | 44 return events; |
| 43 } | 45 } |
| 44 | 46 |
| 45 | 47 |
| 46 // Unregister the file descriptor for a SocketData structure with epoll. | 48 // Unregister the file descriptor for a DescriptorInfo structure with |
| 47 static void RemoveFromEpollInstance(intptr_t epoll_fd_, SocketData* sd) { | 49 // epoll. |
| 50 static void RemoveFromEpollInstance(intptr_t epoll_fd_, |
| 51 DescriptorInfo* di) { |
| 48 VOID_NO_RETRY_EXPECTED(epoll_ctl(epoll_fd_, | 52 VOID_NO_RETRY_EXPECTED(epoll_ctl(epoll_fd_, |
| 49 EPOLL_CTL_DEL, | 53 EPOLL_CTL_DEL, |
| 50 sd->fd(), | 54 di->fd(), |
| 51 NULL)); | 55 NULL)); |
| 52 } | 56 } |
| 53 | 57 |
| 54 | 58 |
| 55 static void AddToEpollInstance(intptr_t epoll_fd_, SocketData* sd) { | 59 static void AddToEpollInstance(intptr_t epoll_fd_, DescriptorInfo* di) { |
| 56 struct epoll_event event; | 60 struct epoll_event event; |
| 57 event.events = EPOLLRDHUP | sd->GetPollEvents(); | 61 event.events = EPOLLRDHUP | di->GetPollEvents(); |
| 58 if (!sd->IsListeningSocket()) { | 62 if (!di->IsListeningSocket()) { |
| 59 event.events |= EPOLLET; | 63 event.events |= EPOLLET; |
| 60 } | 64 } |
| 61 event.data.ptr = sd; | 65 event.data.ptr = di; |
| 62 int status = NO_RETRY_EXPECTED(epoll_ctl(epoll_fd_, | 66 int status = NO_RETRY_EXPECTED(epoll_ctl(epoll_fd_, |
| 63 EPOLL_CTL_ADD, | 67 EPOLL_CTL_ADD, |
| 64 sd->fd(), | 68 di->fd(), |
| 65 &event)); | 69 &event)); |
| 66 if (status == -1) { | 70 if (status == -1) { |
| 71 // TODO(dart:io): Verify that the dart end is handling this correctly. |
| 72 |
| 67 // Epoll does not accept the file descriptor. It could be due to | 73 // Epoll does not accept the file descriptor. It could be due to |
| 68 // already closed file descriptor, or unuspported devices, such | 74 // already closed file descriptor, or unuspported devices, such |
| 69 // as /dev/null. In such case, mark the file descriptor as closed, | 75 // as /dev/null. In such case, mark the file descriptor as closed, |
| 70 // so dart will handle it accordingly. | 76 // so dart will handle it accordingly. |
| 71 DartUtils::PostInt32(sd->port(), 1 << kCloseEvent); | 77 di->NotifyAllDartPorts(1 << kCloseEvent); |
| 72 } | 78 } |
| 73 } | 79 } |
| 74 | 80 |
| 75 | 81 |
| 76 EventHandlerImplementation::EventHandlerImplementation() | 82 EventHandlerImplementation::EventHandlerImplementation() |
| 77 : socket_map_(&HashMap::SamePointerValue, 16) { | 83 : socket_map_(&HashMap::SamePointerValue, 16) { |
| 78 intptr_t result; | 84 intptr_t result; |
| 79 result = NO_RETRY_EXPECTED(pipe(interrupt_fds_)); | 85 result = NO_RETRY_EXPECTED(pipe(interrupt_fds_)); |
| 80 if (result != 0) { | 86 if (result != 0) { |
| 81 FATAL("Pipe creation failed"); | 87 FATAL("Pipe creation failed"); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 | 128 |
| 123 | 129 |
| 124 EventHandlerImplementation::~EventHandlerImplementation() { | 130 EventHandlerImplementation::~EventHandlerImplementation() { |
| 125 VOID_TEMP_FAILURE_RETRY(close(epoll_fd_)); | 131 VOID_TEMP_FAILURE_RETRY(close(epoll_fd_)); |
| 126 VOID_TEMP_FAILURE_RETRY(close(timer_fd_)); | 132 VOID_TEMP_FAILURE_RETRY(close(timer_fd_)); |
| 127 VOID_TEMP_FAILURE_RETRY(close(interrupt_fds_[0])); | 133 VOID_TEMP_FAILURE_RETRY(close(interrupt_fds_[0])); |
| 128 VOID_TEMP_FAILURE_RETRY(close(interrupt_fds_[1])); | 134 VOID_TEMP_FAILURE_RETRY(close(interrupt_fds_[1])); |
| 129 } | 135 } |
| 130 | 136 |
| 131 | 137 |
| 132 SocketData* EventHandlerImplementation::GetSocketData(intptr_t fd, | 138 void EventHandlerImplementation::UpdateEpollInstance(intptr_t old_mask, |
| 133 bool is_listening) { | 139 DescriptorInfo *di) { |
| 140 intptr_t new_mask = di->Mask(); |
| 141 if (old_mask != 0 && new_mask == 0) { |
| 142 RemoveFromEpollInstance(epoll_fd_, di); |
| 143 } else if (old_mask == 0 && new_mask != 0) { |
| 144 AddToEpollInstance(epoll_fd_, di); |
| 145 } else if (old_mask != 0 && new_mask != 0) { |
| 146 if (di->IsListeningSocket()) { |
| 147 ASSERT(old_mask == new_mask); |
| 148 } else { |
| 149 RemoveFromEpollInstance(epoll_fd_, di); |
| 150 AddToEpollInstance(epoll_fd_, di); |
| 151 } |
| 152 } |
| 153 } |
| 154 |
| 155 |
| 156 DescriptorInfo* EventHandlerImplementation::GetDescriptorInfo( |
| 157 intptr_t fd, bool is_listening) { |
| 134 ASSERT(fd >= 0); | 158 ASSERT(fd >= 0); |
| 135 HashMap::Entry* entry = socket_map_.Lookup( | 159 HashMap::Entry* entry = socket_map_.Lookup( |
| 136 GetHashmapKeyFromFd(fd), GetHashmapHashFromFd(fd), true); | 160 GetHashmapKeyFromFd(fd), GetHashmapHashFromFd(fd), true); |
| 137 ASSERT(entry != NULL); | 161 ASSERT(entry != NULL); |
| 138 SocketData* sd = reinterpret_cast<SocketData*>(entry->value); | 162 DescriptorInfo* di = |
| 139 if (sd == NULL) { | 163 reinterpret_cast<DescriptorInfo*>(entry->value); |
| 164 if (di == NULL) { |
| 140 // If there is no data in the hash map for this file descriptor a | 165 // If there is no data in the hash map for this file descriptor a |
| 141 // new SocketData for the file descriptor is inserted. | 166 // new DescriptorInfo for the file descriptor is inserted. |
| 142 if (is_listening) { | 167 if (is_listening) { |
| 143 sd = new ListeningSocketData(fd); | 168 di = new DescriptorInfoMultiple(fd); |
| 144 } else { | 169 } else { |
| 145 sd = new SocketData(fd); | 170 di = new DescriptorInfoSingle(fd); |
| 146 } | 171 } |
| 147 entry->value = sd; | 172 entry->value = di; |
| 148 } | 173 } |
| 149 ASSERT(fd == sd->fd()); | 174 ASSERT(fd == di->fd()); |
| 150 return sd; | 175 return di; |
| 151 } | 176 } |
| 152 | 177 |
| 153 | 178 |
| 154 void EventHandlerImplementation::WakeupHandler(intptr_t id, | 179 void EventHandlerImplementation::WakeupHandler(intptr_t id, |
| 155 Dart_Port dart_port, | 180 Dart_Port dart_port, |
| 156 int64_t data) { | 181 int64_t data) { |
| 157 InterruptMessage msg; | 182 InterruptMessage msg; |
| 158 msg.id = id; | 183 msg.id = id; |
| 159 msg.dart_port = dart_port; | 184 msg.dart_port = dart_port; |
| 160 msg.data = data; | 185 msg.data = data; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 188 it.it_value.tv_sec = millis / 1000; | 213 it.it_value.tv_sec = millis / 1000; |
| 189 it.it_value.tv_nsec = (millis % 1000) * 1000000; | 214 it.it_value.tv_nsec = (millis % 1000) * 1000000; |
| 190 } | 215 } |
| 191 VOID_NO_RETRY_EXPECTED( | 216 VOID_NO_RETRY_EXPECTED( |
| 192 timerfd_settime(timer_fd_, TFD_TIMER_ABSTIME, &it, NULL)); | 217 timerfd_settime(timer_fd_, TFD_TIMER_ABSTIME, &it, NULL)); |
| 193 } else if (msg[i].id == kShutdownId) { | 218 } else if (msg[i].id == kShutdownId) { |
| 194 shutdown_ = true; | 219 shutdown_ = true; |
| 195 } else { | 220 } else { |
| 196 ASSERT((msg[i].data & COMMAND_MASK) != 0); | 221 ASSERT((msg[i].data & COMMAND_MASK) != 0); |
| 197 | 222 |
| 198 SocketData* sd = GetSocketData( | 223 DescriptorInfo* di = GetDescriptorInfo( |
| 199 msg[i].id, IS_LISTENING_SOCKET(msg[i].data)); | 224 msg[i].id, IS_LISTENING_SOCKET(msg[i].data)); |
| 200 if (IS_COMMAND(msg[i].data, kShutdownReadCommand)) { | 225 if (IS_COMMAND(msg[i].data, kShutdownReadCommand)) { |
| 201 ASSERT(!sd->IsListeningSocket()); | 226 ASSERT(!di->IsListeningSocket()); |
| 202 // Close the socket for reading. | 227 // Close the socket for reading. |
| 203 VOID_NO_RETRY_EXPECTED(shutdown(sd->fd(), SHUT_RD)); | 228 VOID_NO_RETRY_EXPECTED(shutdown(di->fd(), SHUT_RD)); |
| 204 } else if (IS_COMMAND(msg[i].data, kShutdownWriteCommand)) { | 229 } else if (IS_COMMAND(msg[i].data, kShutdownWriteCommand)) { |
| 205 ASSERT(!sd->IsListeningSocket()); | 230 ASSERT(!di->IsListeningSocket()); |
| 206 // Close the socket for writing. | 231 // Close the socket for writing. |
| 207 VOID_NO_RETRY_EXPECTED(shutdown(sd->fd(), SHUT_WR)); | 232 VOID_NO_RETRY_EXPECTED(shutdown(di->fd(), SHUT_WR)); |
| 208 } else if (IS_COMMAND(msg[i].data, kCloseCommand)) { | 233 } else if (IS_COMMAND(msg[i].data, kCloseCommand)) { |
| 209 // Close the socket and free system resources and move on to next | 234 // Close the socket and free system resources and move on to next |
| 210 // message. | 235 // message. |
| 211 if (sd->RemovePort(msg[i].dart_port)) { | 236 intptr_t old_mask = di->Mask(); |
| 212 RemoveFromEpollInstance(epoll_fd_, sd); | 237 Dart_Port port = msg[i].dart_port; |
| 213 intptr_t fd = sd->fd(); | 238 di->RemovePort(port); |
| 214 sd->Close(); | 239 intptr_t new_mask = di->Mask(); |
| 215 socket_map_.Remove(GetHashmapKeyFromFd(fd), GetHashmapHashFromFd(fd)); | 240 UpdateEpollInstance(old_mask, di); |
| 216 delete sd; | 241 |
| 242 intptr_t fd = di->fd(); |
| 243 if (di->IsListeningSocket()) { |
| 244 // We only close the socket file descriptor from the operating |
| 245 // system if there are no other dart socket objects which |
| 246 // are listening on the same (address, port) combination. |
| 247 |
| 248 // TODO(dart:io): This assumes that all sockets listen before we |
| 249 // close. |
| 250 // This needs to be synchronized with a global datastructure. |
| 251 if (new_mask == 0) { |
| 252 socket_map_.Remove( |
| 253 GetHashmapKeyFromFd(fd), GetHashmapHashFromFd(fd)); |
| 254 di->Close(); |
| 255 delete di; |
| 256 } |
| 257 } else { |
| 258 ASSERT(new_mask == 0); |
| 259 socket_map_.Remove( |
| 260 GetHashmapKeyFromFd(fd), GetHashmapHashFromFd(fd)); |
| 261 di->Close(); |
| 262 delete di; |
| 217 } | 263 } |
| 218 DartUtils::PostInt32(msg[i].dart_port, 1 << kDestroyedEvent); | 264 |
| 265 DartUtils::PostInt32(port, 1 << kDestroyedEvent); |
| 219 } else if (IS_COMMAND(msg[i].data, kReturnTokenCommand)) { | 266 } else if (IS_COMMAND(msg[i].data, kReturnTokenCommand)) { |
| 220 int count = TOKEN_COUNT(msg[i].data); | 267 int count = TOKEN_COUNT(msg[i].data); |
| 221 if (sd->ReturnToken(msg[i].dart_port, count)) { | 268 intptr_t old_mask = di->Mask(); |
| 222 AddToEpollInstance(epoll_fd_, sd); | 269 di->ReturnTokens(msg[i].dart_port, count); |
| 223 } | 270 UpdateEpollInstance(old_mask, di); |
| 224 } else if (IS_COMMAND(msg[i].data, kSetEventMaskCommand)) { | 271 } else if (IS_COMMAND(msg[i].data, kSetEventMaskCommand)) { |
| 225 // `events` can only have kInEvent/kOutEvent flags set. | 272 // `events` can only have kInEvent/kOutEvent flags set. |
| 226 intptr_t events = msg[i].data & EVENT_MASK; | 273 intptr_t events = msg[i].data & EVENT_MASK; |
| 227 ASSERT(0 == (events & ~(1 << kInEvent | 1 << kOutEvent))); | 274 ASSERT(0 == (events & ~(1 << kInEvent | 1 << kOutEvent))); |
| 228 | 275 |
| 229 // Setup events to wait for. | 276 intptr_t old_mask = di->Mask(); |
| 230 if (sd->AddPort(msg[i].dart_port)) { | 277 di->SetPortAndMask(msg[i].dart_port, msg[i].data & EVENT_MASK); |
| 231 sd->SetMask(events); | 278 UpdateEpollInstance(old_mask, di); |
| 232 AddToEpollInstance(epoll_fd_, sd); | |
| 233 } | |
| 234 } else { | 279 } else { |
| 235 UNREACHABLE(); | 280 UNREACHABLE(); |
| 236 } | 281 } |
| 237 } | 282 } |
| 238 } | 283 } |
| 239 } | 284 } |
| 240 | 285 |
| 241 #ifdef DEBUG_POLL | 286 #ifdef DEBUG_POLL |
| 242 static void PrintEventMask(intptr_t fd, intptr_t events) { | 287 static void PrintEventMask(intptr_t fd, intptr_t events) { |
| 243 Log::Print("%d ", fd); | 288 Log::Print("%d ", fd); |
| 244 if ((events & EPOLLIN) != 0) Log::Print("EPOLLIN "); | 289 if ((events & EPOLLIN) != 0) Log::Print("EPOLLIN "); |
| 245 if ((events & EPOLLPRI) != 0) Log::Print("EPOLLPRI "); | 290 if ((events & EPOLLPRI) != 0) Log::Print("EPOLLPRI "); |
| 246 if ((events & EPOLLOUT) != 0) Log::Print("EPOLLOUT "); | 291 if ((events & EPOLLOUT) != 0) Log::Print("EPOLLOUT "); |
| 247 if ((events & EPOLLERR) != 0) Log::Print("EPOLLERR "); | 292 if ((events & EPOLLERR) != 0) Log::Print("EPOLLERR "); |
| 248 if ((events & EPOLLHUP) != 0) Log::Print("EPOLLHUP "); | 293 if ((events & EPOLLHUP) != 0) Log::Print("EPOLLHUP "); |
| 249 if ((events & EPOLLRDHUP) != 0) Log::Print("EPOLLRDHUP "); | 294 if ((events & EPOLLRDHUP) != 0) Log::Print("EPOLLRDHUP "); |
| 250 int all_events = EPOLLIN | EPOLLPRI | EPOLLOUT | | 295 int all_events = EPOLLIN | EPOLLPRI | EPOLLOUT | |
| 251 EPOLLERR | EPOLLHUP | EPOLLRDHUP; | 296 EPOLLERR | EPOLLHUP | EPOLLRDHUP; |
| 252 if ((events & ~all_events) != 0) { | 297 if ((events & ~all_events) != 0) { |
| 253 Log::Print("(and %08x) ", events & ~all_events); | 298 Log::Print("(and %08x) ", events & ~all_events); |
| 254 } | 299 } |
| 255 Log::Print("(available %d) ", FDUtils::AvailableBytes(fd)); | 300 Log::Print("(available %d) ", FDUtils::AvailableBytes(fd)); |
| 256 | 301 |
| 257 Log::Print("\n"); | 302 Log::Print("\n"); |
| 258 } | 303 } |
| 259 #endif | 304 #endif |
| 260 | 305 |
| 261 intptr_t EventHandlerImplementation::GetPollEvents(intptr_t events, | 306 intptr_t EventHandlerImplementation::GetPollEvents(intptr_t events, |
| 262 SocketData* sd) { | 307 DescriptorInfo* di) { |
| 263 #ifdef DEBUG_POLL | 308 #ifdef DEBUG_POLL |
| 264 PrintEventMask(sd->fd(), events); | 309 PrintEventMask(di->fd(), events); |
| 265 #endif | 310 #endif |
| 266 if (events & EPOLLERR) { | 311 if (events & EPOLLERR) { |
| 267 // Return error only if EPOLLIN is present. | 312 // Return error only if EPOLLIN is present. |
| 268 return (events & EPOLLIN) ? (1 << kErrorEvent) : 0; | 313 return (events & EPOLLIN) ? (1 << kErrorEvent) : 0; |
| 269 } | 314 } |
| 270 intptr_t event_mask = 0; | 315 intptr_t event_mask = 0; |
| 271 if (events & EPOLLIN) event_mask |= (1 << kInEvent); | 316 if (events & EPOLLIN) event_mask |= (1 << kInEvent); |
| 272 if (events & EPOLLOUT) event_mask |= (1 << kOutEvent); | 317 if (events & EPOLLOUT) event_mask |= (1 << kOutEvent); |
| 273 if (events & (EPOLLHUP | EPOLLRDHUP)) event_mask |= (1 << kCloseEvent); | 318 if (events & (EPOLLHUP | EPOLLRDHUP)) event_mask |= (1 << kCloseEvent); |
| 274 return event_mask; | 319 return event_mask; |
| 275 } | 320 } |
| 276 | 321 |
| 277 | 322 |
| 278 void EventHandlerImplementation::HandleEvents(struct epoll_event* events, | 323 void EventHandlerImplementation::HandleEvents(struct epoll_event* events, |
| 279 int size) { | 324 int size) { |
| 280 bool interrupt_seen = false; | 325 bool interrupt_seen = false; |
| 281 for (int i = 0; i < size; i++) { | 326 for (int i = 0; i < size; i++) { |
| 282 if (events[i].data.ptr == NULL) { | 327 if (events[i].data.ptr == NULL) { |
| 283 interrupt_seen = true; | 328 interrupt_seen = true; |
| 284 } else if (events[i].data.fd == timer_fd_) { | 329 } else if (events[i].data.fd == timer_fd_) { |
| 285 int64_t val; | 330 int64_t val; |
| 286 VOID_TEMP_FAILURE_RETRY_NO_SIGNAL_BLOCKER( | 331 VOID_TEMP_FAILURE_RETRY_NO_SIGNAL_BLOCKER( |
| 287 read(timer_fd_, &val, sizeof(val))); | 332 read(timer_fd_, &val, sizeof(val))); |
| 288 if (timeout_queue_.HasTimeout()) { | 333 if (timeout_queue_.HasTimeout()) { |
| 289 DartUtils::PostNull(timeout_queue_.CurrentPort()); | 334 DartUtils::PostNull(timeout_queue_.CurrentPort()); |
| 290 timeout_queue_.RemoveCurrent(); | 335 timeout_queue_.RemoveCurrent(); |
| 291 } | 336 } |
| 292 } else { | 337 } else { |
| 293 SocketData* sd = reinterpret_cast<SocketData*>(events[i].data.ptr); | 338 DescriptorInfo* di = |
| 294 intptr_t event_mask = GetPollEvents(events[i].events, sd); | 339 reinterpret_cast<DescriptorInfo*>(events[i].data.ptr); |
| 340 intptr_t event_mask = GetPollEvents(events[i].events, di); |
| 341 |
| 342 if ((event_mask & (1 << kErrorEvent)) != 0) { |
| 343 di->NotifyAllDartPorts(event_mask); |
| 344 } |
| 345 event_mask &= ~(1 << kErrorEvent); |
| 346 |
| 295 if (event_mask != 0) { | 347 if (event_mask != 0) { |
| 296 Dart_Port port = sd->port(); | 348 intptr_t old_mask = di->Mask(); |
| 297 if (sd->TakeToken()) { | 349 Dart_Port port = di->NextNotifyDartPort(event_mask); |
| 298 // Took last token, remove from epoll. | |
| 299 RemoveFromEpollInstance(epoll_fd_, sd); | |
| 300 } | |
| 301 ASSERT(port != 0); | 350 ASSERT(port != 0); |
| 351 UpdateEpollInstance(old_mask, di); |
| 302 DartUtils::PostInt32(port, event_mask); | 352 DartUtils::PostInt32(port, event_mask); |
| 303 } | 353 } |
| 304 } | 354 } |
| 305 } | 355 } |
| 306 if (interrupt_seen) { | 356 if (interrupt_seen) { |
| 307 // Handle after socket events, so we avoid closing a socket before we handle | 357 // Handle after socket events, so we avoid closing a socket before we handle |
| 308 // the current events. | 358 // the current events. |
| 309 HandleInterruptFd(); | 359 HandleInterruptFd(); |
| 310 } | 360 } |
| 311 } | 361 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 | 414 |
| 365 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { | 415 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { |
| 366 // The hashmap does not support keys with value 0. | 416 // The hashmap does not support keys with value 0. |
| 367 return dart::Utils::WordHash(fd + 1); | 417 return dart::Utils::WordHash(fd + 1); |
| 368 } | 418 } |
| 369 | 419 |
| 370 } // namespace bin | 420 } // namespace bin |
| 371 } // namespace dart | 421 } // namespace dart |
| 372 | 422 |
| 373 #endif // defined(TARGET_OS_LINUX) | 423 #endif // defined(TARGET_OS_LINUX) |
| OLD | NEW |