You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by jp...@apache.org on 2017/10/12 18:31:06 UTC

[1/2] mesos git commit: Removed support for platforms without O_CLOEXEC.

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 <jp...@apache.org>
Authored: Thu Oct 12 10:33:41 2017 -0700
Committer: James Peach <jp...@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


[2/2] mesos git commit: Document the Linux build requirements.

Posted by jp...@apache.org.
Document the Linux build requirements.

Since O_CLOEXEC was introduces in Linux 2.6.3, document that we require
at least this kernel version to build (and run) correctly.

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


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

Branch: refs/heads/master
Commit: 32f571ca74ed0666c02636c84eae8fd8fcfd052d
Parents: eef78fc
Author: James Peach <jp...@apache.org>
Authored: Thu Oct 12 10:33:47 2017 -0700
Committer: James Peach <jp...@apache.org>
Committed: Thu Oct 12 10:33:47 2017 -0700

----------------------------------------------------------------------
 docs/getting-started.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/32f571ca/docs/getting-started.md
----------------------------------------------------------------------
diff --git a/docs/getting-started.md b/docs/getting-started.md
index 7496a10..da1471e 100644
--- a/docs/getting-started.md
+++ b/docs/getting-started.md
@@ -24,7 +24,7 @@ There are different ways you can get Mesos:
 
 Mesos runs on Linux (64 Bit) and Mac OS X (64 Bit). To build Mesos from source, GCC 4.8.1+ or Clang 3.5+ is required.
 
-For full support of process isolation under Linux a recent kernel >=3.10 is required.
+On Linux, a kernel version >= 2.6.23 is required at both build time and run time. For full support of process isolation under Linux a recent kernel >= 3.10 is required.
 
 The Mesos agent also runs on Windows. To build Mesos from source, follow the instructions in the [Windows](windows.md) section.