mesos-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jpe...@apache.org
Subject [1/2] mesos git commit: Removed support for platforms without O_CLOEXEC.
Date Thu, 12 Oct 2017 18:31:06 GMT
Repository: mesos
Updated Branches:
  refs/heads/master ef0b4bb72 -> 32f571ca7


Removed support for platforms without O_CLOEXEC.

The `O_CLOEXEC` fallback code was broken since it did not guarantee
to include `fcntl.h` before checking for the `O_CLOEXEC` symbol.
O_CLOEXEC is supported by all reasonably current service platforms,
so we should not need to fall back to compatibility code. So rather
than fixing the fallback code, we can just eliminate it.

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


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

Branch: refs/heads/master
Commit: eef78fc57337fbcdc67e0169190ba8a3cb2e84d7
Parents: ef0b4bb
Author: James Peach <jpeach@apache.org>
Authored: Thu Oct 12 10:33:41 2017 -0700
Committer: James Peach <jpeach@apache.org>
Committed: Thu Oct 12 10:33:41 2017 -0700

----------------------------------------------------------------------
 3rdparty/stout/include/stout/os/open.hpp        | 53 ++------------------
 .../stout/include/stout/os/windows/fcntl.hpp    |  8 +++
 3rdparty/stout/include/stout/windows.hpp        |  8 ---
 3 files changed, 11 insertions(+), 58 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/eef78fc5/3rdparty/stout/include/stout/os/open.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/os/open.hpp b/3rdparty/stout/include/stout/os/open.hpp
index c9346c6..1443b63 100644
--- a/3rdparty/stout/include/stout/os/open.hpp
+++ b/3rdparty/stout/include/stout/os/open.hpp
@@ -23,58 +23,21 @@
 #include <stout/try.hpp>
 
 #include <stout/os/close.hpp>
+#include <stout/os/fcntl.hpp>
 #include <stout/os/int_fd.hpp>
 
 #ifdef __WINDOWS__
-#include <stout/windows.hpp>
 #include <stout/internal/windows/longpath.hpp>
 #endif // __WINDOWS__
 
-// For old systems that do not support O_CLOEXEC, we still want
-// os::open to accept that flag so that we can simplify the code.
 #ifndef O_CLOEXEC
-// Since we will define O_CLOEXEC if it is not yet defined, we use a
-// special symbol to tell if the flag is truly unavailable or not.
-#define O_CLOEXEC_UNDEFINED
-
-// NOTE: For backward compatibility concern, kernel usually does not
-// change the constant values for symbols like O_CLOEXEC.
-#if defined(__APPLE__)
-// Copied from '/usr/include/sys/fcntl.h'
-#define O_CLOEXEC 0x1000000
-#elif defined(__linux__)
-// Copied from '/usr/include/asm-generic/fcntl.h'.
-#define O_CLOEXEC 02000000
-#elif defined(__sun)
-// Not defined on Solaris, taking a spare flag.
-#define O_CLOEXEC 0x1000000
-#endif // __ APPLE__
-#endif // O_CLOEXEC
-
-// Only include `fcntl` when strictly necessary, i.e., when we need to use
-// `os::cloexec` to set the close-on-exec behavior of a file descriptor. We do
-// this because some platforms (like Windows) will probably never support
-// `os::cloexec`, and hence referencing that header will cause problems on some
-// systems.
-#ifdef O_CLOEXEC_UNDEFINED
-#include <stout/os/fcntl.hpp>
-#endif // O_CLOEXEC_UNDEFINED
-
+#error "missing O_CLOEXEC support on this platform"
+#endif
 
 namespace os {
 
 inline Try<int_fd> open(const std::string& path, int oflag, mode_t mode = 0)
 {
-#ifdef O_CLOEXEC_UNDEFINED
-  // Before we passing oflag to ::open, we need to strip the O_CLOEXEC
-  // flag since it's not supported.
-  bool cloexec = false;
-  if ((oflag & O_CLOEXEC) != 0) {
-    oflag &= ~O_CLOEXEC;
-    cloexec = true;
-  }
-#endif
-
 #ifdef __WINDOWS__
   std::wstring longpath = ::internal::windows::longpath(path);
   int_fd fd = ::_wopen(longpath.data(), oflag, mode);
@@ -85,16 +48,6 @@ inline Try<int_fd> open(const std::string& path, int oflag, mode_t
mode = 0)
     return ErrnoError();
   }
 
-#ifdef O_CLOEXEC_UNDEFINED
-  if (cloexec) {
-    Try<Nothing> result = os::cloexec(fd);
-    if (result.isError()) {
-      os::close(fd);
-      return Error("Failed to set cloexec: " + result.error());
-    }
-  }
-#endif
-
   return fd;
 }
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/eef78fc5/3rdparty/stout/include/stout/os/windows/fcntl.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/os/windows/fcntl.hpp b/3rdparty/stout/include/stout/os/windows/fcntl.hpp
index ac90bf0..5800ec9 100644
--- a/3rdparty/stout/include/stout/os/windows/fcntl.hpp
+++ b/3rdparty/stout/include/stout/os/windows/fcntl.hpp
@@ -22,6 +22,14 @@
 #include <stout/os/socket.hpp>
 #include <stout/os/windows/fd.hpp>
 
+#define O_RDONLY _O_RDONLY
+#define O_WRONLY _O_WRONLY
+#define O_RDWR _O_RDWR
+#define O_CREAT _O_CREAT
+#define O_TRUNC _O_TRUNC
+#define O_APPEND _O_APPEND
+#define O_CLOEXEC _O_NOINHERIT
+
 namespace os {
 
 // NOTE: This is not supported on Windows.

http://git-wip-us.apache.org/repos/asf/mesos/blob/eef78fc5/3rdparty/stout/include/stout/windows.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/windows.hpp b/3rdparty/stout/include/stout/windows.hpp
index fd7ffea..7aa0ba7 100644
--- a/3rdparty/stout/include/stout/windows.hpp
+++ b/3rdparty/stout/include/stout/windows.hpp
@@ -165,14 +165,6 @@ inline BOOL GetMessage(
 #define X_OK 0x0 // No such permission on Windows.
 #define F_OK 0x0
 
-#define O_RDONLY _O_RDONLY
-#define O_WRONLY _O_WRONLY
-#define O_RDWR _O_RDWR
-#define O_CREAT _O_CREAT
-#define O_TRUNC _O_TRUNC
-#define O_APPEND _O_APPEND
-#define O_CLOEXEC _O_NOINHERIT
-
 #define MAXHOSTNAMELEN NI_MAXHOST
 
 #define PATH_MAX _MAX_PATH


Mime
View raw message