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

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

Issue 8662006: Fix a number of issues with the process handling (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Rebase Created 9 years 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) 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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 printf("(and %08x) ", pollfd->revents & ~all_events); 208 printf("(and %08x) ", pollfd->revents & ~all_events);
209 } 209 }
210 printf("(available %d) ", FDUtils::AvailableBytes(pollfd->fd)); 210 printf("(available %d) ", FDUtils::AvailableBytes(pollfd->fd));
211 211
212 printf("\n"); 212 printf("\n");
213 } 213 }
214 #endif 214 #endif
215 215
216 intptr_t EventHandlerImplementation::GetPollEvents(struct pollfd* pollfd) { 216 intptr_t EventHandlerImplementation::GetPollEvents(struct pollfd* pollfd) {
217 #ifdef DEBUG_POLL 217 #ifdef DEBUG_POLL
218 printf("Poll events:\n");
Mads Ager (google) 2011/11/23 12:45:19 Do you want to add this debugging line in the maco
Søren Gjesse 2011/11/23 14:50:18 Yes, to separate each return from poll.
218 if (pollfd->fd != interrupt_fds_[0]) PrintEventMask(pollfd); 219 if (pollfd->fd != interrupt_fds_[0]) PrintEventMask(pollfd);
219 #endif 220 #endif
220 intptr_t event_mask = 0; 221 intptr_t event_mask = 0;
221 SocketData* sd = GetSocketData(pollfd->fd); 222 SocketData* sd = GetSocketData(pollfd->fd);
222 if (sd->IsListeningSocket()) { 223 if (sd->IsListeningSocket()) {
223 // For listening sockets the POLLIN event indicate that there are 224 // For listening sockets the POLLIN event indicate that there are
224 // connections ready for accept unless accompanied with one of the 225 // connections ready for accept unless accompanied with one of the
225 // other flags. 226 // other flags.
226 if ((pollfd->revents & POLLIN) != 0) { 227 if ((pollfd->revents & POLLIN) != 0) {
227 if ((pollfd->revents & POLLHUP) != 0) event_mask |= (1 << kCloseEvent); 228 if ((pollfd->revents & POLLHUP) != 0) event_mask |= (1 << kCloseEvent);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 if (bytesPeeked == 0) { 260 if (bytesPeeked == 0) {
260 event_mask = (1 << kCloseEvent); 261 event_mask = (1 << kCloseEvent);
261 sd->MarkClosedRead(); 262 sd->MarkClosedRead();
262 } else if (errno != EAGAIN) { 263 } else if (errno != EAGAIN) {
263 fprintf(stderr, "Error recv: %s\n", strerror(errno)); 264 fprintf(stderr, "Error recv: %s\n", strerror(errno));
264 } 265 }
265 } 266 }
266 } 267 }
267 } 268 }
268 269
269 // On pipes POLLHUP is reported without POLLIN. 270 // On pipes POLLHUP is reported without POLLIN when there is no
271 // more data to read.
270 if (sd->IsPipe()) { 272 if (sd->IsPipe()) {
271 if (((pollfd->revents & POLLIN) == 0) && 273 if (((pollfd->revents & POLLIN) == 0) &&
272 ((pollfd->revents & POLLHUP) != 0)) { 274 ((pollfd->revents & POLLHUP) != 0)) {
273 event_mask = (1 << kCloseEvent); 275 event_mask = (1 << kCloseEvent);
274 sd->MarkClosedRead(); 276 sd->MarkClosedRead();
275 } 277 }
276 } 278 }
277 279
278 if ((pollfd->revents & POLLOUT) != 0) event_mask |= (1 << kOutEvent); 280 if ((pollfd->revents & POLLOUT) != 0) {
281 if ((pollfd->revents & POLLERR) != 0) {
282 event_mask = (1 << kErrorEvent);
283 sd->MarkClosedWrite();
284 } else {
285 event_mask |= (1 << kOutEvent);
286 }
287 }
279 } 288 }
280 289
281 return event_mask; 290 return event_mask;
282 } 291 }
283 292
284 293
285 void EventHandlerImplementation::HandleEvents(struct pollfd* pollfds, 294 void EventHandlerImplementation::HandleEvents(struct pollfd* pollfds,
286 int pollfds_size, 295 int pollfds_size,
287 int result_size) { 296 int result_size) {
288 if ((pollfds[0].revents & POLLIN) != 0) { 297 if ((pollfds[0].revents & POLLIN) != 0) {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 FATAL("Create start event handler thread"); 370 FATAL("Create start event handler thread");
362 } 371 }
363 } 372 }
364 373
365 374
366 void EventHandlerImplementation::SendData(intptr_t id, 375 void EventHandlerImplementation::SendData(intptr_t id,
367 Dart_Port dart_port, 376 Dart_Port dart_port,
368 intptr_t data) { 377 intptr_t data) {
369 WakeupHandler(id, dart_port, data); 378 WakeupHandler(id, dart_port, data);
370 } 379 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698