mesos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mp...@apache.org
Subject [3/4] mesos git commit: Windows: Used `sendfile` with the typed error state of `Try`.
Date Mon, 25 Apr 2016 22:18:33 GMT
Windows: Used `sendfile` with the typed error state of `Try`.

Review: https://reviews.apache.org/r/46285/


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/a10237a7
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/a10237a7
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/a10237a7

Branch: refs/heads/master
Commit: a10237a7d53320bf3a717fe310aec4de54015f36
Parents: 4e352e4
Author: Daniel Pravat <dpravat@outlook.com>
Authored: Thu Apr 21 22:55:27 2016 -0700
Committer: Michael Park <mpark@apache.org>
Committed: Mon Apr 25 14:34:16 2016 -0700

----------------------------------------------------------------------
 3rdparty/libprocess/src/poll_socket.cpp | 36 +++++++++++++---------------
 1 file changed, 16 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/a10237a7/3rdparty/libprocess/src/poll_socket.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/poll_socket.cpp b/3rdparty/libprocess/src/poll_socket.cpp
index f6abc73..e68c783 100644
--- a/3rdparty/libprocess/src/poll_socket.cpp
+++ b/3rdparty/libprocess/src/poll_socket.cpp
@@ -209,33 +209,29 @@ Future<size_t> socket_send_file(int s, int fd, off_t offset, size_t
size)
   CHECK(size > 0);
 
   while (true) {
-    ssize_t length = os::sendfile(s, fd, offset, size);
+    Try<ssize_t, SocketError> length = os::sendfile(s, fd, offset, size);
 
-    if (length < 0 && (errno == EINTR)) {
+    if (length.isSome()) {
+      CHECK(length.get() >= 0);
+      if (length.get() == 0) {
+        // Socket closed.
+        VLOG(1) << "Socket closed while sending";
+      }
+      return length.get();
+    }
+
+    if (net::is_restartable_error(length.error().code)) {
       // Interrupted, try again now.
       continue;
-    } else if (length < 0 && (errno == EAGAIN || errno == EWOULDBLOCK)) {
+    } else if (net::is_retryable_error(length.error().code)) {
       // Might block, try again later.
       return io::poll(s, io::WRITE)
         .then(lambda::bind(&internal::socket_send_file, s, fd, offset, size));
-    } else if (length <= 0) {
-      // Socket error or closed.
-      if (length < 0) {
-        const string error = os::strerror(errno);
-        VLOG(1) << "Socket error while sending: " << error;
-      } else {
-        VLOG(1) << "Socket closed while sending";
-      }
-      if (length == 0) {
-        return length;
-      } else {
-        return Failure(ErrnoError("Socket sendfile failed"));
-      }
     } else {
-      CHECK(length > 0);
-
-      return length;
-    }
+      // Socket error or closed.
+      VLOG(1) << length.error().message;
+      return Failure(length.error());
+    };
   }
 }
 


Mime
View raw message