You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by jo...@apache.org on 2016/03/24 10:27:09 UTC
[11/11] mesos git commit: Windows: Used os::read/write from Stout for
proper OS isolation.
Windows: Used os::read/write from Stout for proper OS isolation.
Review: https://reviews.apache.org/r/44089/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/ed26c1bd
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/ed26c1bd
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/ed26c1bd
Branch: refs/heads/master
Commit: ed26c1bd36897b0d27f30e53eadb02baf4ee9089
Parents: 8fd56e7
Author: Daniel Pravat <dp...@outlook.com>
Authored: Thu Mar 24 09:33:32 2016 +0100
Committer: Joris Van Remoortere <jo...@gmail.com>
Committed: Thu Mar 24 10:26:50 2016 +0100
----------------------------------------------------------------------
3rdparty/libprocess/src/io.cpp | 26 +++++++++++++++++++++-----
1 file changed, 21 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/ed26c1bd/3rdparty/libprocess/src/io.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/io.cpp b/3rdparty/libprocess/src/io.cpp
index 4a58d6d..dd77793 100644
--- a/3rdparty/libprocess/src/io.cpp
+++ b/3rdparty/libprocess/src/io.cpp
@@ -22,7 +22,9 @@
#include <stout/lambda.hpp>
#include <stout/nothing.hpp>
#include <stout/os.hpp>
+#include <stout/os/read.hpp>
#include <stout/os/strerror.hpp>
+#include <stout/os/write.hpp>
#include <stout/try.hpp>
using std::string;
@@ -65,15 +67,23 @@ void read(
} else {
ssize_t length;
if (flags == NONE) {
- length = ::read(fd, data, size);
+ length = os::read(fd, data, size);
} else { // PEEK.
// In case 'fd' is not a socket ::recv() will fail with ENOTSOCK and the
// error will be propagted out.
- length = ::recv(fd, data, size, MSG_PEEK);
+ // NOTE: We cast to `char*` here because the function prototypes on
+ // Windows use `char*` instead of `void*`.
+ length = ::recv(fd, (char*) data, size, MSG_PEEK);
}
+#ifdef __WINDOWS__
+ int error = WSAGetLastError();
+#else
+ int error = errno;
+#endif // __WINDOWS__
+
if (length < 0) {
- if (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK) {
+ if (net::is_restartable_error(error) || net::is_retryable_error(error)) {
// Restart the read operation.
Future<short> future =
io::poll(fd, process::io::READ).onAny(
@@ -123,10 +133,16 @@ void write(
} else if (future.isFailed()) {
promise->fail(future.failure());
} else {
- ssize_t length = ::write(fd, data, size);
+ ssize_t length = os::write(fd, data, size);
+
+#ifdef __WINDOWS__
+ int error = WSAGetLastError();
+#else
+ int error = errno;
+#endif // __WINDOWS__
if (length < 0) {
- if (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK) {
+ if (net::is_restartable_error(error) || net::is_retryable_error(error)) {
// Restart the write operation.
Future<short> future =
io::poll(fd, process::io::WRITE).onAny(