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

Unified Diff: runtime/bin/fdutils_macos.cc

Issue 9139011: Handle EINTR on all IO operations (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixed building on Mac OS Created 8 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/fdutils_linux.cc ('k') | runtime/bin/file_linux.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/fdutils_macos.cc
diff --git a/runtime/bin/fdutils_macos.cc b/runtime/bin/fdutils_macos.cc
index d92b6608c52ce598477d32b36a045fe264214619..4aeccb4b6769292e9220809afab53afeedec4de0 100644
--- a/runtime/bin/fdutils_macos.cc
+++ b/runtime/bin/fdutils_macos.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
@@ -12,13 +12,13 @@
bool FDUtils::SetNonBlocking(intptr_t fd) {
intptr_t status;
- status = fcntl(fd, F_GETFL);
+ status = TEMP_FAILURE_RETRY(fcntl(fd, F_GETFL));
if (status < 0) {
perror("fcntl F_GETFL failed");
return false;
}
status = (status | O_NONBLOCK);
- if (fcntl(fd, F_SETFL, status) < 0) {
+ if (TEMP_FAILURE_RETRY(fcntl(fd, F_SETFL, status)) < 0) {
perror("fcntl F_SETFL failed");
return false;
}
@@ -28,7 +28,7 @@ bool FDUtils::SetNonBlocking(intptr_t fd) {
bool FDUtils::IsBlocking(intptr_t fd, bool* is_blocking) {
intptr_t status;
- status = fcntl(fd, F_GETFL);
+ status = TEMP_FAILURE_RETRY(fcntl(fd, F_GETFL));
if (status < 0) {
perror("fcntl F_GETFL failed");
return false;
@@ -40,7 +40,7 @@ bool FDUtils::IsBlocking(intptr_t fd, bool* is_blocking) {
intptr_t FDUtils::AvailableBytes(intptr_t fd) {
size_t available;
- int result = ioctl(fd, FIONREAD, &available);
+ int result = TEMP_FAILURE_RETRY(ioctl(fd, FIONREAD, &available));
if (result < 0) {
return result;
}
@@ -57,19 +57,19 @@ ssize_t FDUtils::ReadFromBlocking(int fd, void* buffer, size_t count) {
size_t remaining = count;
char* buffer_pos = reinterpret_cast<char*>(buffer);
while (remaining > 0) {
- ssize_t bytes_read = read(fd, buffer_pos, remaining);
+ ssize_t bytes_read = TEMP_FAILURE_RETRY(read(fd, buffer_pos, remaining));
if (bytes_read == 0) {
return count - remaining;
- } else if (bytes_read == -1 && errno != EINTR) {
- // Error codes EAGAIN and EWOULDBLOCK should only happen for non
- // blocking file descriptors.
- ASSERT(errno != EAGAIN && errno != EWOULDBLOCK);
+ } else if (bytes_read == -1) {
+ ASSERT(EAGAIN == EWOULDBLOCK);
+ // Error code EWOULDBLOCK should only happen for non blocking
+ // file descriptors.
+ ASSERT(errno != EWOULDBLOCK);
return -1;
- } else if (bytes_read > 0) {
+ } else {
+ ASSERT((bytes_read > 0));
remaining -= bytes_read;
buffer_pos += bytes_read;
- } else {
- ASSERT(errno == EINTR);
}
}
return count;
@@ -85,19 +85,20 @@ ssize_t FDUtils::WriteToBlocking(int fd, const void* buffer, size_t count) {
size_t remaining = count;
char* buffer_pos = const_cast<char*>(reinterpret_cast<const char*>(buffer));
while (remaining > 0) {
- ssize_t bytes_written = write(fd, buffer_pos, remaining);
+ ssize_t bytes_written =
+ TEMP_FAILURE_RETRY(write(fd, buffer_pos, remaining));
if (bytes_written == 0) {
return count - remaining;
- } else if (bytes_written == -1 && errno != EINTR) {
- // Error codes EAGAIN and EWOULDBLOCK should only happen for non
- // blocking file descriptors.
- ASSERT(errno != EAGAIN && errno != EWOULDBLOCK);
+ } else if (bytes_written == -1) {
+ ASSERT(EAGAIN == EWOULDBLOCK);
+ // Error code EWOULDBLOCK should only happen for non blocking
+ // file descriptors.
+ ASSERT(errno != EWOULDBLOCK);
return -1;
- } else if (bytes_written > 0) {
+ } else {
+ ASSERT(bytes_written > 0);
remaining -= bytes_written;
buffer_pos += bytes_written;
- } else {
- ASSERT(errno == EINTR);
}
}
return count;
« no previous file with comments | « runtime/bin/fdutils_linux.cc ('k') | runtime/bin/file_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698