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

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

Issue 8383037: Improve error handling in the process library. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 9 years, 1 month 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 | « runtime/bin/eventhandler_linux.cc ('k') | runtime/bin/file.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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 <errno.h> 5 #include <errno.h>
6 #include <poll.h> 6 #include <poll.h>
7 #include <pthread.h> 7 #include <pthread.h>
8 #include <stdio.h> 8 #include <stdio.h>
9 #include <string.h> 9 #include <string.h>
10 #include <sys/time.h> 10 #include <sys/time.h>
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 free(port_map_); 53 free(port_map_);
54 close(interrupt_fds_[0]); 54 close(interrupt_fds_[0]);
55 close(interrupt_fds_[1]); 55 close(interrupt_fds_[1]);
56 } 56 }
57 57
58 58
59 // TODO(hpayer): Use hash table instead of array. 59 // TODO(hpayer): Use hash table instead of array.
60 void EventHandlerImplementation::SetPort(intptr_t fd, 60 void EventHandlerImplementation::SetPort(intptr_t fd,
61 Dart_Port dart_port, 61 Dart_Port dart_port,
62 intptr_t mask) { 62 intptr_t mask) {
63 assert(fd >= 0); 63 ASSERT(fd >= 0);
64 if (fd >= port_map_size_) { 64 if (fd >= port_map_size_) {
65 intptr_t new_port_map_size = port_map_size_; 65 intptr_t new_port_map_size = port_map_size_;
66 do { 66 do {
67 new_port_map_size = new_port_map_size * kPortMapGrowingFactor; 67 new_port_map_size = new_port_map_size * kPortMapGrowingFactor;
68 } while (fd >= new_port_map_size); 68 } while (fd >= new_port_map_size);
69 size_t new_port_map_bytes = new_port_map_size * sizeof(PortData); 69 size_t new_port_map_bytes = new_port_map_size * sizeof(PortData);
70 port_map_ = reinterpret_cast<PortData*>(realloc(port_map_, 70 port_map_ = reinterpret_cast<PortData*>(realloc(port_map_,
71 new_port_map_bytes)); 71 new_port_map_bytes));
72 ASSERT(port_map_ != NULL); 72 ASSERT(port_map_ != NULL);
73 size_t port_map_bytes = port_map_size_ * sizeof(PortData); 73 size_t port_map_bytes = port_map_size_ * sizeof(PortData);
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
247 if (result_size > 0) { 247 if (result_size > 0) {
248 for (int i = 1; i < pollfds_size; i++) { 248 for (int i = 1; i < pollfds_size; i++) {
249 /* 249 /*
250 * The fd is unregistered. It gets re-registered when the request 250 * The fd is unregistered. It gets re-registered when the request
251 * was handled by dart. 251 * was handled by dart.
252 */ 252 */
253 intptr_t event_mask = GetPollEvents(&pollfds[i]); 253 intptr_t event_mask = GetPollEvents(&pollfds[i]);
254 if (event_mask != 0) { 254 if (event_mask != 0) {
255 intptr_t fd = pollfds[i].fd; 255 intptr_t fd = pollfds[i].fd;
256 Dart_Port port = PortFor(fd); 256 Dart_Port port = PortFor(fd);
257 assert(port != 0); 257 ASSERT(port != 0);
258 UnregisterFd(fd); 258 UnregisterFd(fd);
259 Dart_PostIntArray(port, 1, &event_mask); 259 Dart_PostIntArray(port, 1, &event_mask);
260 } 260 }
261 } 261 }
262 } 262 }
263 HandleInterruptFd(); 263 HandleInterruptFd();
264 } 264 }
265 265
266 266
267 intptr_t EventHandlerImplementation::GetTimeout() { 267 intptr_t EventHandlerImplementation::GetTimeout() {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 FATAL("Create start event handler thread"); 316 FATAL("Create start event handler thread");
317 } 317 }
318 } 318 }
319 319
320 320
321 void EventHandlerImplementation::SendData(intptr_t id, 321 void EventHandlerImplementation::SendData(intptr_t id,
322 Dart_Port dart_port, 322 Dart_Port dart_port,
323 intptr_t data) { 323 intptr_t data) {
324 RegisterFdWakeup(id, dart_port, data); 324 RegisterFdWakeup(id, dart_port, data);
325 } 325 }
OLDNEW
« no previous file with comments | « runtime/bin/eventhandler_linux.cc ('k') | runtime/bin/file.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698