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

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

Issue 9720045: Extend dart:io error handling to all socket functions (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments Created 8 years, 9 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
« no previous file with comments | « runtime/bin/builtin_natives.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) 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 "bin/eventhandler.h" 5 #include "bin/eventhandler.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <pthread.h> 8 #include <pthread.h>
9 #include <stdio.h> 9 #include <stdio.h>
10 #include <string.h> 10 #include <string.h>
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 if ((events & EPOLLIN) != 0) { 254 if ((events & EPOLLIN) != 0) {
255 if ((events & EPOLLHUP) != 0) event_mask |= (1 << kCloseEvent); 255 if ((events & EPOLLHUP) != 0) event_mask |= (1 << kCloseEvent);
256 if ((events & EPOLLERR) != 0) event_mask |= (1 << kErrorEvent); 256 if ((events & EPOLLERR) != 0) event_mask |= (1 << kErrorEvent);
257 if (event_mask == 0) event_mask |= (1 << kInEvent); 257 if (event_mask == 0) event_mask |= (1 << kInEvent);
258 } 258 }
259 } else { 259 } else {
260 // Prioritize data events over close and error events. 260 // Prioritize data events over close and error events.
261 if ((events & EPOLLIN) != 0) { 261 if ((events & EPOLLIN) != 0) {
262 if (FDUtils::AvailableBytes(sd->fd()) != 0) { 262 if (FDUtils::AvailableBytes(sd->fd()) != 0) {
263 event_mask = (1 << kInEvent); 263 event_mask = (1 << kInEvent);
264 } else if (((events & EPOLLHUP) != 0)) { 264 } else if ((events & EPOLLHUP) != 0) {
265 event_mask = (1 << kCloseEvent); 265 // If both EPOLLHUP and EPOLLERR are reported treat it as an
266 // error.
267 if ((events & EPOLLERR) != 0) {
268 event_mask = (1 << kErrorEvent);
269 } else {
270 event_mask = (1 << kCloseEvent);
271 }
266 sd->MarkClosedRead(); 272 sd->MarkClosedRead();
267 } else if ((events & EPOLLERR) != 0) { 273 } else if ((events & EPOLLERR) != 0) {
268 event_mask = (1 << kErrorEvent); 274 event_mask = (1 << kErrorEvent);
269 } else { 275 } else {
270 if (sd->IsPipe()) { 276 if (sd->IsPipe()) {
271 // When reading from stdin (either from a terminal or piped 277 // When reading from stdin (either from a terminal or piped
272 // input) treat EPOLLIN with 0 available bytes as 278 // input) treat EPOLLIN with 0 available bytes as
273 // end-of-file. 279 // end-of-file.
274 if (sd->fd() == STDIN_FILENO) { 280 if (sd->fd() == STDIN_FILENO) {
275 event_mask = (1 << kCloseEvent); 281 event_mask = (1 << kCloseEvent);
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 void* EventHandlerImplementation::GetHashmapKeyFromFd(intptr_t fd) { 409 void* EventHandlerImplementation::GetHashmapKeyFromFd(intptr_t fd) {
404 // The hashmap does not support keys with value 0. 410 // The hashmap does not support keys with value 0.
405 return reinterpret_cast<void*>(fd + 1); 411 return reinterpret_cast<void*>(fd + 1);
406 } 412 }
407 413
408 414
409 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { 415 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) {
410 // The hashmap does not support keys with value 0. 416 // The hashmap does not support keys with value 0.
411 return dart::Utils::WordHash(fd + 1); 417 return dart::Utils::WordHash(fd + 1);
412 } 418 }
OLDNEW
« no previous file with comments | « runtime/bin/builtin_natives.cc ('k') | runtime/bin/eventhandler_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698