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

Unified Diff: src/platform-posix.cc

Issue 10412021: Make socket send and receive more robust and return 0 on failure. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 7 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
Index: src/platform-posix.cc
diff --git a/src/platform-posix.cc b/src/platform-posix.cc
index 66316594c8ce3fdfe90cc4fd296f08325b653eb5..3e143d2f6441f78929c4784384e20fbfca85b47b 100644
--- a/src/platform-posix.cc
+++ b/src/platform-posix.cc
@@ -1,4 +1,4 @@
-// Copyright 2011 the V8 project authors. All rights reserved.
+// Copyright 2012 the V8 project authors. All rights reserved.
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
@@ -467,14 +467,16 @@ bool POSIXSocket::Shutdown() {
int POSIXSocket::Send(const char* data, int len) const {
+ if (len <= 0) return 0;
int status = send(socket_, data, len, 0);
- return status;
+ return (status < 0) ? 0 : status;
}
int POSIXSocket::Receive(char* data, int len) const {
+ if (len <= 0) return 0;
int status = recv(socket_, data, len, 0);
- return status;
+ return (status < 0) ? 0 : status;
}
« src/debug-agent.cc ('K') | « src/platform.h ('k') | src/platform-win32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698