| OLD | NEW |
| 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 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 if (bytesPeeked == 0) { | 259 if (bytesPeeked == 0) { |
| 260 event_mask = (1 << kCloseEvent); | 260 event_mask = (1 << kCloseEvent); |
| 261 sd->MarkClosedRead(); | 261 sd->MarkClosedRead(); |
| 262 } else if (errno != EAGAIN) { | 262 } else if (errno != EAGAIN) { |
| 263 fprintf(stderr, "Error recv: %s\n", strerror(errno)); | 263 fprintf(stderr, "Error recv: %s\n", strerror(errno)); |
| 264 } | 264 } |
| 265 } | 265 } |
| 266 } | 266 } |
| 267 } | 267 } |
| 268 | 268 |
| 269 // On pipes POLLHUP is reported without POLLIN. | 269 // On pipes POLLHUP is reported without POLLIN when there is no |
| 270 // more data to read. |
| 270 if (sd->IsPipe()) { | 271 if (sd->IsPipe()) { |
| 271 if (((pollfd->revents & POLLIN) == 0) && | 272 if (((pollfd->revents & POLLIN) == 0) && |
| 272 ((pollfd->revents & POLLHUP) != 0)) { | 273 ((pollfd->revents & POLLHUP) != 0)) { |
| 273 event_mask = (1 << kCloseEvent); | 274 event_mask = (1 << kCloseEvent); |
| 274 sd->MarkClosedRead(); | 275 sd->MarkClosedRead(); |
| 275 } | 276 } |
| 276 } | 277 } |
| 277 | 278 |
| 278 if ((pollfd->revents & POLLOUT) != 0) event_mask |= (1 << kOutEvent); | 279 if ((pollfd->revents & POLLOUT) != 0) { |
| 280 if ((pollfd->revents & POLLERR) != 0) { |
| 281 event_mask = (1 << kErrorEvent); |
| 282 sd->MarkClosedWrite(); |
| 283 } else { |
| 284 event_mask |= (1 << kOutEvent); |
| 285 } |
| 286 } |
| 279 } | 287 } |
| 280 | 288 |
| 281 return event_mask; | 289 return event_mask; |
| 282 } | 290 } |
| 283 | 291 |
| 284 | 292 |
| 285 void EventHandlerImplementation::HandleEvents(struct pollfd* pollfds, | 293 void EventHandlerImplementation::HandleEvents(struct pollfd* pollfds, |
| 286 int pollfds_size, | 294 int pollfds_size, |
| 287 int result_size) { | 295 int result_size) { |
| 288 if ((pollfds[0].revents & POLLIN) != 0) { | 296 if ((pollfds[0].revents & POLLIN) != 0) { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 FATAL("Create start event handler thread"); | 369 FATAL("Create start event handler thread"); |
| 362 } | 370 } |
| 363 } | 371 } |
| 364 | 372 |
| 365 | 373 |
| 366 void EventHandlerImplementation::SendData(intptr_t id, | 374 void EventHandlerImplementation::SendData(intptr_t id, |
| 367 Dart_Port dart_port, | 375 Dart_Port dart_port, |
| 368 intptr_t data) { | 376 intptr_t data) { |
| 369 WakeupHandler(id, dart_port, data); | 377 WakeupHandler(id, dart_port, data); |
| 370 } | 378 } |
| OLD | NEW |