mesos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bmah...@apache.org
Subject [2/3] git commit: Updated process.cpp to use os::sendfile.
Date Mon, 05 Aug 2013 19:51:16 GMT
Updated process.cpp to use os::sendfile.

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


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

Branch: refs/heads/master
Commit: dab4665c84077982b36bbcc6f7c1d40d0f144489
Parents: 14d2214
Author: Benjamin Mahler <bmahler@twitter.com>
Authored: Thu Jun 27 18:55:09 2013 -0700
Committer: Benjamin Mahler <bmahler@twitter.com>
Committed: Mon Aug 5 12:38:06 2013 -0700

----------------------------------------------------------------------
 3rdparty/libprocess/src/config.hpp  | 9 ---------
 3rdparty/libprocess/src/process.cpp | 5 ++++-
 2 files changed, 4 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/dab4665c/3rdparty/libprocess/src/config.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/config.hpp b/3rdparty/libprocess/src/config.hpp
index 1daa476..cbaf41d 100644
--- a/3rdparty/libprocess/src/config.hpp
+++ b/3rdparty/libprocess/src/config.hpp
@@ -27,21 +27,12 @@
 #ifndef MAP_32BIT
 #define MAP_32BIT 0
 #endif
-#define sendfile(s, fd, offset, size) \
-  ({ off_t length = size; \
-    sendfile(fd, s, offset, &length, NULL, 0) == 0 \
-      ? length \
-      : (errno == EAGAIN ? (length > 0 ? length : -1) : -1); })
 #endif /* __APPLE__ */
 
 #ifdef __linux__
 #ifndef MAP_32BIT
 #define MAP_32BIT 0
 #endif
-#include <sys/sendfile.h>
-#define sendfile(s, fd, offset, size) \
-  ({ off_t _offset = offset; \
-    sendfile(s, fd, &_offset, size) == -1 ? -1 : _offset - offset; })
 #endif /* __linux__ */
 
 #endif /* CONFIG_HPP */

http://git-wip-us.apache.org/repos/asf/mesos/blob/dab4665c/3rdparty/libprocess/src/process.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/process.cpp b/3rdparty/libprocess/src/process.cpp
index 443acfd..0b4f90f 100644
--- a/3rdparty/libprocess/src/process.cpp
+++ b/3rdparty/libprocess/src/process.cpp
@@ -1093,7 +1093,7 @@ void send_file(struct ev_loop* loop, ev_io* watcher, int revents)
     fd = encoder->next(&offset, &size);
     CHECK(size > 0);
 
-    ssize_t length = sendfile(s, fd, offset, size);
+    ssize_t length = os::sendfile(s, fd, offset, size);
 
     if (length < 0 && (errno == EINTR)) {
       // Interrupted, try again now.
@@ -3609,6 +3609,7 @@ Future<Response> get(const UPID& upid, const string& path,
const string& query)
   addr.sin_addr.s_addr = upid.ip;
 
   if (connect(s, (sockaddr*) &addr, sizeof(addr)) < 0) {
+    os::close(s);
     return Future<Response>::failed(
         string("Failed to connect: ") + strerror(errno));
   }
@@ -3640,6 +3641,7 @@ Future<Response> get(const UPID& upid, const string& path,
const string& query)
       if (errno == EINTR) {
         continue;
       }
+      os::close(s);
       return Future<Response>::failed(
           string("Failed to write: ") + strerror(errno));
     }
@@ -3649,6 +3651,7 @@ Future<Response> get(const UPID& upid, const string& path,
const string& query)
 
   Try<Nothing> nonblock = os::nonblock(s);
   if (!nonblock.isSome()) {
+    os::close(s);
     return Future<Response>::failed(
         "Failed to set nonblock: " + nonblock.error());
   }


Mime
View raw message