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

Side by Side Diff: runtime/bin/eventhandler_linux.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.cc ('k') | runtime/bin/eventhandler_macos.cc » ('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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 if (result_size > 0) { 249 if (result_size > 0) {
250 for (int i = 1; i < pollfds_size; i++) { 250 for (int i = 1; i < pollfds_size; i++) {
251 /* 251 /*
252 * The fd is unregistered. It gets re-registered when the request 252 * The fd is unregistered. It gets re-registered when the request
253 * was handled by dart. 253 * was handled by dart.
254 */ 254 */
255 intptr_t event_mask = GetPollEvents(&pollfds[i]); 255 intptr_t event_mask = GetPollEvents(&pollfds[i]);
256 if (event_mask != 0) { 256 if (event_mask != 0) {
257 intptr_t fd = pollfds[i].fd; 257 intptr_t fd = pollfds[i].fd;
258 Dart_Port port = PortFor(fd); 258 Dart_Port port = PortFor(fd);
259 assert(port != 0); 259 ASSERT(port != 0);
260 UnregisterFd(fd); 260 UnregisterFd(fd);
261 Dart_PostIntArray(port, 1, &event_mask); 261 Dart_PostIntArray(port, 1, &event_mask);
262 } 262 }
263 } 263 }
264 } 264 }
265 HandleInterruptFd(); 265 HandleInterruptFd();
266 } 266 }
267 267
268 268
269 intptr_t EventHandlerImplementation::GetTimeout() { 269 intptr_t EventHandlerImplementation::GetTimeout() {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 FATAL("Create start event handler thread"); 318 FATAL("Create start event handler thread");
319 } 319 }
320 } 320 }
321 321
322 322
323 void EventHandlerImplementation::SendData(intptr_t id, 323 void EventHandlerImplementation::SendData(intptr_t id,
324 Dart_Port dart_port, 324 Dart_Port dart_port,
325 intptr_t data) { 325 intptr_t data) {
326 RegisterFdWakeup(id, dart_port, data); 326 RegisterFdWakeup(id, dart_port, data);
327 } 327 }
OLDNEW
« no previous file with comments | « runtime/bin/eventhandler.cc ('k') | runtime/bin/eventhandler_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698