mesos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From andsc...@apache.org
Subject [01/10] mesos git commit: Windows: Added overlapped field to `WindowsFD`.
Date Wed, 23 May 2018 21:36:45 GMT
Repository: mesos
Updated Branches:
  refs/heads/master 40177c893 -> 21305ab47


Windows: Added overlapped field to `WindowsFD`.

Added a field to `WindowsFD` for functions that need to know if a
Windows file is opened in overlapped mode, such as `os::read`, since
Windows doesn't provide a Win32 API for it.

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


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

Branch: refs/heads/master
Commit: 3e21c50e4847debae3d8def2f48b6a44e36c3109
Parents: 40177c8
Author: Akash Gupta <akash-gupta@hotmail.com>
Authored: Wed May 23 14:00:13 2018 -0700
Committer: Andrew Schwartzmeyer <andrew@schwartzmeyer.com>
Committed: Wed May 23 14:00:13 2018 -0700

----------------------------------------------------------------------
 3rdparty/stout/include/stout/os/windows/dup.hpp  |  2 +-
 3rdparty/stout/include/stout/os/windows/fd.hpp   | 16 ++++++++++++++--
 3rdparty/stout/include/stout/os/windows/open.hpp |  4 ++++
 3 files changed, 19 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/3e21c50e/3rdparty/stout/include/stout/os/windows/dup.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/os/windows/dup.hpp b/3rdparty/stout/include/stout/os/windows/dup.hpp
index af98054..5bda095 100644
--- a/3rdparty/stout/include/stout/os/windows/dup.hpp
+++ b/3rdparty/stout/include/stout/os/windows/dup.hpp
@@ -40,7 +40,7 @@ inline Try<int_fd> dup(const int_fd& fd)
         return WindowsError();
       }
 
-      return duplicate;
+      return int_fd(duplicate, fd.is_overlapped());
     }
     case WindowsFD::Type::SOCKET: {
       WSAPROTOCOL_INFOW info;

http://git-wip-us.apache.org/repos/asf/mesos/blob/3e21c50e/3rdparty/stout/include/stout/os/windows/fd.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/os/windows/fd.hpp b/3rdparty/stout/include/stout/os/windows/fd.hpp
index bab16e8..5dbdff2 100644
--- a/3rdparty/stout/include/stout/os/windows/fd.hpp
+++ b/3rdparty/stout/include/stout/os/windows/fd.hpp
@@ -68,15 +68,23 @@ public:
   static_assert(
       std::is_same<HANDLE, void*>::value,
       "Expected `HANDLE` to be of type `void*`.");
-  explicit WindowsFD(HANDLE handle) : type_(Type::HANDLE), handle_(handle) {}
+  explicit WindowsFD(HANDLE handle, bool overlapped = false)
+    : type_(Type::HANDLE), handle_(handle), overlapped_(overlapped)
+  {}
 
   // The `SOCKET` here is expected to be Windows sockets, such as that
   // used by the Windows Sockets 2 library. The only expected error
   // value is `INVALID_SOCKET`.
+  //
+  // Note that sockets should almost always be overlapped. We do provide
+  // a way in stout to create non-overlapped sockets, so for completeness, we
+  // have an overlapped parameter in the constructor.
   static_assert(
       std::is_same<SOCKET, unsigned __int64>::value,
       "Expected `SOCKET` to be of type `unsigned __int64`.");
-  explicit WindowsFD(SOCKET socket) : type_(Type::SOCKET), socket_(socket) {}
+  explicit WindowsFD(SOCKET socket, bool overlapped = true)
+    : type_(Type::SOCKET), socket_(socket), overlapped_(overlapped)
+  {}
 
   // On Windows, libevent's `evutil_socket_t` is set to `intptr_t`.
   explicit WindowsFD(intptr_t socket) : WindowsFD(static_cast<SOCKET>(socket))
@@ -161,6 +169,8 @@ public:
 
   Type type() const { return type_; }
 
+  bool is_overlapped() const { return overlapped_; }
+
 private:
   Type type_;
 
@@ -170,6 +180,8 @@ private:
     SOCKET socket_;
   };
 
+  bool overlapped_;
+
   // NOTE: This function is provided only for checking validity, thus
   // it is private. It provides a view of a `WindowsFD` as an `int`.
   //

http://git-wip-us.apache.org/repos/asf/mesos/blob/3e21c50e/3rdparty/stout/include/stout/os/windows/open.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/os/windows/open.hpp b/3rdparty/stout/include/stout/os/windows/open.hpp
index 701dcec..b2f033c 100644
--- a/3rdparty/stout/include/stout/os/windows/open.hpp
+++ b/3rdparty/stout/include/stout/os/windows/open.hpp
@@ -44,6 +44,10 @@ namespace os {
 
 // TODO(andschwa): Handle specified creation permissions in `mode_t mode`. See
 // MESOS-3176.
+//
+// NOTE: This function always opens files in non-overlapped mode, because
+// we only support overlapped pipes and sockets through the `os::pipe`
+// and `os::socket` functions.
 inline Try<int_fd> open(const std::string& path, int oflag, mode_t mode = 0)
 {
   std::wstring longpath = ::internal::windows::longpath(path);


Mime
View raw message