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

Unified Diff: runtime/bin/socket_linux.cc

Issue 8659032: Fix memory leak in MacOS process handling. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review comments. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/socket_impl.dart ('k') | runtime/bin/socket_macos.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/socket_linux.cc
diff --git a/runtime/bin/socket_linux.cc b/runtime/bin/socket_linux.cc
index 8910a8200828d82f62c25a52661c7461512689ec..39e5edb5e74c2fdf1405b0c82467ba019746a861 100644
--- a/runtime/bin/socket_linux.cc
+++ b/runtime/bin/socket_linux.cc
@@ -63,6 +63,12 @@ intptr_t Socket::Available(intptr_t fd) {
int Socket::Read(intptr_t fd, void* buffer, intptr_t num_bytes) {
ASSERT(fd >= 0);
ssize_t read_bytes = read(fd, buffer, num_bytes);
+ if (read_bytes == -1 &&
+ (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR)) {
+ // If the read was interrupted or the read would block we need
+ // to retry and therefore return 0 as the number of bytes written.
+ read_bytes = 0;
+ }
return read_bytes;
}
@@ -70,6 +76,12 @@ int Socket::Read(intptr_t fd, void* buffer, intptr_t num_bytes) {
int Socket::Write(intptr_t fd, const void* buffer, intptr_t num_bytes) {
ASSERT(fd >= 0);
ssize_t written_bytes = write(fd, buffer, num_bytes);
+ if (written_bytes == -1 &&
+ (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR)) {
+ // If the write was interrupted or the write would block we need
+ // to retry and therefore return 0 as the number of bytes written.
+ written_bytes = 0;
+ }
return written_bytes;
}
« no previous file with comments | « runtime/bin/socket_impl.dart ('k') | runtime/bin/socket_macos.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698