mesos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jo...@apache.org
Subject [2/9] mesos git commit: Libprocess: Implemented `HANDLE` versions of file descriptor functions.
Date Mon, 23 May 2016 23:49:03 GMT
Libprocess: Implemented `HANDLE` versions of file descriptor functions.

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


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

Branch: refs/heads/master
Commit: 4155145c8973859c4dfb55856708c3c782660461
Parents: 490c532
Author: Alex Clemmer <clemmer.alexander@gmail.com>
Authored: Mon May 23 16:09:08 2016 -0700
Committer: Joris Van Remoortere <joris.van.remoortere@gmail.com>
Committed: Mon May 23 16:48:48 2016 -0700

----------------------------------------------------------------------
 3rdparty/libprocess/include/process/io.hpp | 11 +++++++++++
 3rdparty/libprocess/src/io.cpp             | 23 +++++++++++++++++++++++
 2 files changed, 34 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/4155145c/3rdparty/libprocess/include/process/io.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/io.hpp b/3rdparty/libprocess/include/process/io.hpp
index 2f1e626..fed246b 100644
--- a/3rdparty/libprocess/include/process/io.hpp
+++ b/3rdparty/libprocess/include/process/io.hpp
@@ -19,6 +19,9 @@
 #include <process/future.hpp>
 
 #include <stout/nothing.hpp>
+#ifdef __WINDOWS__
+#include <stout/windows.hpp>
+#endif // __WINDOWS__
 
 namespace process {
 namespace io {
@@ -78,6 +81,10 @@ Future<size_t> read(int fd, void* data, size_t size);
  *     or made non-blocking.
  */
 Future<std::string> read(int fd);
+#ifdef __WINDOWS__
+// Version of this function compatible with Windows `HANDLE`.
+Future<std::string> read(HANDLE fd);
+#endif // __WINDOWS__
 
 
 /**
@@ -119,6 +126,10 @@ Future<Nothing> write(int fd, const std::string& data);
  *     set to close-on-exec, or made non-blocking.
  */
 Future<Nothing> redirect(int from, Option<int> to, size_t chunk = 4096);
+#ifdef __WINDOWS__
+// Version of this function compatible with Windows `HANDLE`.
+Future<Nothing> redirect(HANDLE from, Option<int> to, size_t chunk = 4096);
+#endif // __WINDOWS__
 
 
 /**

http://git-wip-us.apache.org/repos/asf/mesos/blob/4155145c/3rdparty/libprocess/src/io.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/io.cpp b/3rdparty/libprocess/src/io.cpp
index 44dee23..d9c6075 100644
--- a/3rdparty/libprocess/src/io.cpp
+++ b/3rdparty/libprocess/src/io.cpp
@@ -444,6 +444,16 @@ Future<string> read(int fd)
 }
 
 
+#ifdef __WINDOWS__
+// NOTE: Ordinarily this would go in a Windows-specific header; we put it here
+// to avoid complex forward declarations.
+Future<string> read(HANDLE handle)
+{
+  return read(_open_osfhandle(reinterpret_cast<intptr_t>(handle), O_RDONLY));
+}
+#endif // __WINDOWS__
+
+
 Future<Nothing> write(int fd, const string& data)
 {
   process::initialize();
@@ -558,6 +568,19 @@ Future<Nothing> redirect(int from, Option<int> to, size_t
chunk)
 }
 
 
+#ifdef __WINDOWS__
+// NOTE: Ordinarily this would go in a Windows-specific header; we put it here
+// to avoid complex forward declarations.
+Future<Nothing> redirect(HANDLE from, Option<int> to, size_t chunk)
+{
+  return redirect(
+      _open_osfhandle(reinterpret_cast<intptr_t>(from), O_RDWR),
+      to,
+      chunk);
+}
+#endif // __WINDOWS__
+
+
 // TODO(hartem): Most of the boilerplate code here is the same as
 // in io::read, so this needs to be refactored.
 Future<string> peek(int fd, size_t limit)


Mime
View raw message