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

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

Issue 14864009: Keep track of when a socket has been destroyed (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Patch cleanup. Created 7 years, 5 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
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 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 ASSERT(msg.data == (1 << kShutdownReadCommand)); 201 ASSERT(msg.data == (1 << kShutdownReadCommand));
202 // Close the socket for reading. 202 // Close the socket for reading.
203 sd->ShutdownRead(); 203 sd->ShutdownRead();
204 UpdateEpollInstance(epoll_fd_, sd); 204 UpdateEpollInstance(epoll_fd_, sd);
205 } else if ((msg.data & (1 << kShutdownWriteCommand)) != 0) { 205 } else if ((msg.data & (1 << kShutdownWriteCommand)) != 0) {
206 ASSERT(msg.data == (1 << kShutdownWriteCommand)); 206 ASSERT(msg.data == (1 << kShutdownWriteCommand));
207 // Close the socket for writing. 207 // Close the socket for writing.
208 sd->ShutdownWrite(); 208 sd->ShutdownWrite();
209 UpdateEpollInstance(epoll_fd_, sd); 209 UpdateEpollInstance(epoll_fd_, sd);
210 } else if ((msg.data & (1 << kCloseCommand)) != 0) { 210 } else if ((msg.data & (1 << kCloseCommand)) != 0) {
211 ASSERT(msg.data == (1 << kCloseCommand)); 211 ASSERT(msg.data == (1 << kCloseCommand));
kustermann 2013/07/18 11:34:46 This assert will be hit, if 'msg.data == kCloseCo
Anders Johnsen 2013/07/19 10:49:07 Removed in other file.
212 // Close the socket and free system resources and move on to 212 // Close the socket and free system resources and move on to
213 // next message. 213 // next message.
214 RemoveFromEpollInstance(epoll_fd_, sd); 214 RemoveFromEpollInstance(epoll_fd_, sd);
215 intptr_t fd = sd->fd(); 215 intptr_t fd = sd->fd();
216 if (fd == STDOUT_FILENO) { 216 if (fd == STDOUT_FILENO) {
217 // If stdout, redirect fd to /dev/null. 217 // If stdout, redirect fd to /dev/null.
218 int null_fd = TEMP_FAILURE_RETRY(open("/dev/null", O_WRONLY)); 218 int null_fd = TEMP_FAILURE_RETRY(open("/dev/null", O_WRONLY));
219 ASSERT(null_fd >= 0); 219 ASSERT(null_fd >= 0);
220 VOID_TEMP_FAILURE_RETRY(dup2(null_fd, STDOUT_FILENO)); 220 VOID_TEMP_FAILURE_RETRY(dup2(null_fd, STDOUT_FILENO));
221 VOID_TEMP_FAILURE_RETRY(close(null_fd)); 221 VOID_TEMP_FAILURE_RETRY(close(null_fd));
222 } else { 222 } else {
223 sd->Close(); 223 sd->Close();
224 } 224 }
225 socket_map_.Remove(GetHashmapKeyFromFd(fd), GetHashmapHashFromFd(fd)); 225 socket_map_.Remove(GetHashmapKeyFromFd(fd), GetHashmapHashFromFd(fd));
226 delete sd; 226 delete sd;
227 DartUtils::PostInt32(msg.dart_port, 1 << kDestroyedEvent);
227 } else { 228 } else {
228 // Setup events to wait for. 229 // Setup events to wait for.
229 sd->SetPortAndMask(msg.dart_port, msg.data); 230 sd->SetPortAndMask(msg.dart_port, msg.data);
230 UpdateEpollInstance(epoll_fd_, sd); 231 UpdateEpollInstance(epoll_fd_, sd);
231 } 232 }
232 } 233 }
233 } 234 }
234 } 235 }
235 236
236 #ifdef DEBUG_POLL 237 #ifdef DEBUG_POLL
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 435
435 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { 436 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) {
436 // The hashmap does not support keys with value 0. 437 // The hashmap does not support keys with value 0.
437 return dart::Utils::WordHash(fd + 1); 438 return dart::Utils::WordHash(fd + 1);
438 } 439 }
439 440
440 } // namespace bin 441 } // namespace bin
441 } // namespace dart 442 } // namespace dart
442 443
443 #endif // defined(TARGET_OS_ANDROID) 444 #endif // defined(TARGET_OS_ANDROID)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698