Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(132)

Side by Side Diff: dart/runtime/bin/eventhandler_android.cc

Issue 665823007: Several bugfixes in dart:io's handing of sockets (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Added two spaces as requested Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « dart/runtime/bin/eventhandler.h ('k') | dart/runtime/bin/eventhandler_linux.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_ANDROID) 6 #if defined(TARGET_OS_ANDROID)
7 7
8 #include "bin/eventhandler.h" 8 #include "bin/eventhandler.h"
9 9
10 #include <errno.h> // NOLINT 10 #include <errno.h> // NOLINT
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 InterruptMessage msg[MAX_MESSAGES]; 167 InterruptMessage msg[MAX_MESSAGES];
168 ssize_t bytes = TEMP_FAILURE_RETRY_NO_SIGNAL_BLOCKER( 168 ssize_t bytes = TEMP_FAILURE_RETRY_NO_SIGNAL_BLOCKER(
169 read(interrupt_fds_[0], msg, MAX_MESSAGES * kInterruptMessageSize)); 169 read(interrupt_fds_[0], msg, MAX_MESSAGES * kInterruptMessageSize));
170 for (ssize_t i = 0; i < bytes / kInterruptMessageSize; i++) { 170 for (ssize_t i = 0; i < bytes / kInterruptMessageSize; i++) {
171 if (msg[i].id == kTimerId) { 171 if (msg[i].id == kTimerId) {
172 timeout_queue_.UpdateTimeout(msg[i].dart_port, msg[i].data); 172 timeout_queue_.UpdateTimeout(msg[i].dart_port, msg[i].data);
173 } else if (msg[i].id == kShutdownId) { 173 } else if (msg[i].id == kShutdownId) {
174 shutdown_ = true; 174 shutdown_ = true;
175 } else { 175 } else {
176 SocketData* sd = GetSocketData(msg[i].id); 176 SocketData* sd = GetSocketData(msg[i].id);
177 if ((msg[i].data & (1 << kShutdownReadCommand)) != 0) { 177
178 ASSERT(msg[i].data == (1 << kShutdownReadCommand)); 178 if (IS_COMMAND(msg[i].data, kShutdownReadCommand)) {
179 // Close the socket for reading. 179 // Close the socket for reading.
180 shutdown(sd->fd(), SHUT_RD); 180 shutdown(sd->fd(), SHUT_RD);
181 } else if ((msg[i].data & (1 << kShutdownWriteCommand)) != 0) { 181 } else if (IS_COMMAND(msg[i].data, kShutdownWriteCommand)) {
182 ASSERT(msg[i].data == (1 << kShutdownWriteCommand));
183 // Close the socket for writing. 182 // Close the socket for writing.
184 shutdown(sd->fd(), SHUT_WR); 183 shutdown(sd->fd(), SHUT_WR);
185 } else if ((msg[i].data & (1 << kCloseCommand)) != 0) { 184 } else if (IS_COMMAND(msg[i].data, kCloseCommand)) {
186 ASSERT(msg[i].data == (1 << kCloseCommand));
187 // Close the socket and free system resources and move on to 185 // Close the socket and free system resources and move on to
188 // next message. 186 // next message.
189 RemoveFromEpollInstance(epoll_fd_, sd); 187 RemoveFromEpollInstance(epoll_fd_, sd);
190 intptr_t fd = sd->fd(); 188 intptr_t fd = sd->fd();
191 sd->Close(); 189 sd->Close();
192 socket_map_.Remove(GetHashmapKeyFromFd(fd), GetHashmapHashFromFd(fd)); 190 socket_map_.Remove(GetHashmapKeyFromFd(fd), GetHashmapHashFromFd(fd));
193 delete sd; 191 delete sd;
194 DartUtils::PostInt32(msg[i].dart_port, 1 << kDestroyedEvent); 192 DartUtils::PostInt32(msg[i].dart_port, 1 << kDestroyedEvent);
195 } else if ((msg[i].data & (1 << kReturnTokenCommand)) != 0) { 193 } else if (IS_COMMAND(msg[i].data, kReturnTokenCommand)) {
196 int count = msg[i].data & ((1 << kReturnTokenCommand) - 1); 194 int count = TOKEN_COUNT(msg[i].data);
195
197 for (int i = 0; i < count; i++) { 196 for (int i = 0; i < count; i++) {
198 if (sd->ReturnToken()) { 197 if (sd->ReturnToken()) {
199 AddToEpollInstance(epoll_fd_, sd); 198 AddToEpollInstance(epoll_fd_, sd);
200 } 199 }
201 } 200 }
202 } else { 201 } else {
202 ASSERT_NO_COMMAND(msg[i].data);
203 // Setup events to wait for. 203 // Setup events to wait for.
204 sd->SetPortAndMask(msg[i].dart_port, msg[i].data); 204 sd->SetPortAndMask(msg[i].dart_port, msg[i].data);
205 AddToEpollInstance(epoll_fd_, sd); 205 AddToEpollInstance(epoll_fd_, sd);
206 } 206 }
207 } 207 }
208 } 208 }
209 } 209 }
210 210
211 #ifdef DEBUG_POLL 211 #ifdef DEBUG_POLL
212 static void PrintEventMask(intptr_t fd, intptr_t events) { 212 static void PrintEventMask(intptr_t fd, intptr_t events) {
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 350
351 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { 351 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) {
352 // The hashmap does not support keys with value 0. 352 // The hashmap does not support keys with value 0.
353 return dart::Utils::WordHash(fd + 1); 353 return dart::Utils::WordHash(fd + 1);
354 } 354 }
355 355
356 } // namespace bin 356 } // namespace bin
357 } // namespace dart 357 } // namespace dart
358 358
359 #endif // defined(TARGET_OS_ANDROID) 359 #endif // defined(TARGET_OS_ANDROID)
OLDNEW
« no previous file with comments | « dart/runtime/bin/eventhandler.h ('k') | dart/runtime/bin/eventhandler_linux.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698