You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by ji...@apache.org on 2016/12/07 00:41:35 UTC
[1/3] mesos git commit: Added os::unsetCloexec to stout.
Repository: mesos
Updated Branches:
refs/heads/master f54babdba -> fae793972
Added os::unsetCloexec to stout.
Review: https://reviews.apache.org/r/54432
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/0649ef1a
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/0649ef1a
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/0649ef1a
Branch: refs/heads/master
Commit: 0649ef1ac918f02bd6ed0c6d3d495779683ff955
Parents: f54babd
Author: Jie Yu <yu...@gmail.com>
Authored: Tue Dec 6 09:54:47 2016 -0800
Committer: Jie Yu <yu...@gmail.com>
Committed: Tue Dec 6 16:41:19 2016 -0800
----------------------------------------------------------------------
3rdparty/stout/include/stout/os/posix/fcntl.hpp | 16 ++++++++++++++++
3rdparty/stout/include/stout/os/windows/fcntl.hpp | 10 ++++++++++
3rdparty/stout/tests/os_tests.cpp | 6 ++++++
3 files changed, 32 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/0649ef1a/3rdparty/stout/include/stout/os/posix/fcntl.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/include/stout/os/posix/fcntl.hpp b/3rdparty/stout/include/stout/os/posix/fcntl.hpp
index daaca0d..46b4b57 100644
--- a/3rdparty/stout/include/stout/os/posix/fcntl.hpp
+++ b/3rdparty/stout/include/stout/os/posix/fcntl.hpp
@@ -40,6 +40,22 @@ inline Try<Nothing> cloexec(int fd)
}
+inline Try<Nothing> unsetCloexec(int fd)
+{
+ int flags = ::fcntl(fd, F_GETFD);
+
+ if (flags == -1) {
+ return ErrnoError();
+ }
+
+ if (::fcntl(fd, F_SETFD, flags & ~FD_CLOEXEC) == -1) {
+ return ErrnoError();
+ }
+
+ return Nothing();
+}
+
+
inline Try<bool> isCloexec(int fd)
{
int flags = ::fcntl(fd, F_GETFD);
http://git-wip-us.apache.org/repos/asf/mesos/blob/0649ef1a/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 2bc794a..f331cd3 100644
--- a/3rdparty/stout/include/stout/os/windows/fcntl.hpp
+++ b/3rdparty/stout/include/stout/os/windows/fcntl.hpp
@@ -33,6 +33,16 @@ inline Try<Nothing> cloexec(int fd)
// NOTE: This is not supported on Windows.
+inline Try<Nothing> unsetCloexec(int fd)
+{
+ LOG(WARNING) << "`os::unsetCloexec` has been called, "
+ << "but is a no-op on Windows";
+
+ return Nothing();
+}
+
+
+// NOTE: This is not supported on Windows.
inline Try<bool> isCloexec(int fd)
{
LOG(WARNING) << "`os::isCloexec` has been called, but is a stub on Windows";
http://git-wip-us.apache.org/repos/asf/mesos/blob/0649ef1a/3rdparty/stout/tests/os_tests.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/stout/tests/os_tests.cpp b/3rdparty/stout/tests/os_tests.cpp
index 4462823..bed1449 100644
--- a/3rdparty/stout/tests/os_tests.cpp
+++ b/3rdparty/stout/tests/os_tests.cpp
@@ -132,6 +132,9 @@ TEST_F_TEMP_DISABLED_ON_WINDOWS(OsTest, Cloexec)
ASSERT_SOME(fd);
EXPECT_SOME_TRUE(os::isCloexec(fd.get()));
+ ASSERT_SOME(os::unsetCloexec(fd.get()));
+ EXPECT_SOME_FALSE(os::isCloexec(fd.get()));
+
close(fd.get());
fd = os::open(
@@ -142,6 +145,9 @@ TEST_F_TEMP_DISABLED_ON_WINDOWS(OsTest, Cloexec)
ASSERT_SOME(fd);
EXPECT_SOME_FALSE(os::isCloexec(fd.get()));
+ ASSERT_SOME(os::cloexec(fd.get()));
+ EXPECT_SOME_TRUE(os::isCloexec(fd.get()));
+
close(fd.get());
}
[3/3] mesos git commit: Used UNSET_CLOEXEC instead of DUP2 hook for
I/O switchboard.
Posted by ji...@apache.org.
Used UNSET_CLOEXEC instead of DUP2 hook for I/O switchboard.
Review: https://reviews.apache.org/r/54434
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/fae79397
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/fae79397
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/fae79397
Branch: refs/heads/master
Commit: fae793972021b851667c759250dad9c3309773a0
Parents: 46be1e8
Author: Jie Yu <yu...@gmail.com>
Authored: Tue Dec 6 10:33:18 2016 -0800
Committer: Jie Yu <yu...@gmail.com>
Committed: Tue Dec 6 16:41:20 2016 -0800
----------------------------------------------------------------------
.../containerizer/mesos/io/switchboard.cpp | 24 +++++---------------
.../containerizer/mesos/io/switchboard.hpp | 22 ++++--------------
2 files changed, 11 insertions(+), 35 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/fae79397/src/slave/containerizer/mesos/io/switchboard.cpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/io/switchboard.cpp b/src/slave/containerizer/mesos/io/switchboard.cpp
index e1ca695..c54d64e 100644
--- a/src/slave/containerizer/mesos/io/switchboard.cpp
+++ b/src/slave/containerizer/mesos/io/switchboard.cpp
@@ -498,10 +498,9 @@ Future<Option<ContainerLaunchInfo>> IOSwitchboard::_prepare(
// Set up our flags to send to the io switchboard server process.
IOSwitchboardServerFlags switchboardFlags;
switchboardFlags.tty = hasTTY;
-
- // We use the default values for other file descriptor flags. Since
- // I/O switchboard server's stdout and stderr will be redirected to
- // the logger, we explicitly set the flags here.
+ switchboardFlags.stdin_to_fd = stdinToFd;
+ switchboardFlags.stdout_from_fd = stdoutFromFd;
+ switchboardFlags.stderr_from_fd = stderrFromFd;
switchboardFlags.stdout_to_fd = STDOUT_FILENO;
switchboardFlags.stderr_to_fd = STDERR_FILENO;
@@ -550,15 +549,9 @@ Future<Option<ContainerLaunchInfo>> IOSwitchboard::_prepare(
None(),
{},
{Subprocess::ChildHook::SETSID(),
- Subprocess::ChildHook::DUP2(
- stdinToFd,
- IOSwitchboardServer::STDIN_TO_FD),
- Subprocess::ChildHook::DUP2(
- stdoutFromFd,
- IOSwitchboardServer::STDOUT_FROM_FD),
- Subprocess::ChildHook::DUP2(
- stderrFromFd,
- IOSwitchboardServer::STDERR_FROM_FD)});
+ Subprocess::ChildHook::UNSET_CLOEXEC(stdinToFd),
+ Subprocess::ChildHook::UNSET_CLOEXEC(stdoutFromFd),
+ Subprocess::ChildHook::UNSET_CLOEXEC(stderrFromFd)});
if (child.isError()) {
close(openedFds);
@@ -768,11 +761,6 @@ Future<Nothing> IOSwitchboard::cleanup(
#ifndef __WINDOWS__
const char IOSwitchboardServer::NAME[] = "mesos-io-switchboard";
-const int IOSwitchboardServer::STDIN_TO_FD = STDERR_FILENO + 1;
-const int IOSwitchboardServer::STDOUT_FROM_FD = STDERR_FILENO + 2;
-const int IOSwitchboardServer::STDERR_FROM_FD = STDERR_FILENO + 3;
-const int IOSwitchboardServer::STDOUT_TO_FD = STDERR_FILENO + 4;
-const int IOSwitchboardServer::STDERR_TO_FD = STDERR_FILENO + 5;
class IOSwitchboardServerProcess : public Process<IOSwitchboardServerProcess>
http://git-wip-us.apache.org/repos/asf/mesos/blob/fae79397/src/slave/containerizer/mesos/io/switchboard.hpp
----------------------------------------------------------------------
diff --git a/src/slave/containerizer/mesos/io/switchboard.hpp b/src/slave/containerizer/mesos/io/switchboard.hpp
index a3f19fc..f691b18 100644
--- a/src/slave/containerizer/mesos/io/switchboard.hpp
+++ b/src/slave/containerizer/mesos/io/switchboard.hpp
@@ -123,13 +123,6 @@ class IOSwitchboardServer
public:
static const char NAME[];
- // Constant FD numbers used by I/O switchboard server.
- static const int STDIN_TO_FD;
- static const int STDOUT_FROM_FD;
- static const int STDERR_FROM_FD;
- static const int STDOUT_TO_FD;
- static const int STDERR_TO_FD;
-
static Try<process::Owned<IOSwitchboardServer>> create(
bool tty,
int stdinToFd,
@@ -192,30 +185,25 @@ struct IOSwitchboardServerFlags : public virtual flags::FlagsBase
add(&IOSwitchboardServerFlags::stdin_to_fd,
"stdin_to_fd",
- "The file descriptor where incoming stdin data should be written.",
- IOSwitchboardServer::STDIN_TO_FD);
+ "The file descriptor where incoming stdin data should be written.");
add(&IOSwitchboardServerFlags::stdout_from_fd,
"stdout_from_fd",
- "The file descriptor that should be read to consume stdout data.",
- IOSwitchboardServer::STDOUT_FROM_FD);
+ "The file descriptor that should be read to consume stdout data.");
add(&IOSwitchboardServerFlags::stdout_to_fd,
"stdout_to_fd",
"A file descriptor where data read from\n"
- "'stdout_from_fd' should be redirected to.",
- IOSwitchboardServer::STDOUT_TO_FD);
+ "'stdout_from_fd' should be redirected to.");
add(&IOSwitchboardServerFlags::stderr_from_fd,
"stderr_from_fd",
- "The file descriptor that should be read to consume stderr data.",
- IOSwitchboardServer::STDERR_FROM_FD);
+ "The file descriptor that should be read to consume stderr data.");
add(&IOSwitchboardServerFlags::stderr_to_fd,
"stderr_to_fd",
"A file descriptor where data read from\n"
- "'stderr_from_fd' should be redirected to.",
- IOSwitchboardServer::STDERR_TO_FD);
+ "'stderr_from_fd' should be redirected to.");
add(&IOSwitchboardServerFlags::wait_for_connection,
"wait_for_connection",
[2/3] mesos git commit: Added a UNSET_CLOEXEC child hook to
subprocess.
Posted by ji...@apache.org.
Added a UNSET_CLOEXEC child hook to subprocess.
Review: https://reviews.apache.org/r/54433
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/46be1e80
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/46be1e80
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/46be1e80
Branch: refs/heads/master
Commit: 46be1e806963f724bb9d0b13f5c50e9cdd4f8469
Parents: 0649ef1
Author: Jie Yu <yu...@gmail.com>
Authored: Tue Dec 6 10:04:24 2016 -0800
Committer: Jie Yu <yu...@gmail.com>
Committed: Tue Dec 6 16:41:20 2016 -0800
----------------------------------------------------------------------
3rdparty/libprocess/include/process/subprocess_base.hpp | 6 ++++++
3rdparty/libprocess/src/subprocess.cpp | 8 ++++++++
2 files changed, 14 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/46be1e80/3rdparty/libprocess/include/process/subprocess_base.hpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/include/process/subprocess_base.hpp b/3rdparty/libprocess/include/process/subprocess_base.hpp
index 0d9c74a..74a4bef 100644
--- a/3rdparty/libprocess/include/process/subprocess_base.hpp
+++ b/3rdparty/libprocess/include/process/subprocess_base.hpp
@@ -204,6 +204,12 @@ public:
* `ChildHook` for duplicating a file descriptor.
*/
static ChildHook DUP2(int oldFd, int newFd);
+
+ /**
+ * `ChildHook` to unset CLOEXEC on a file descriptor. This is
+ * useful to explicitly pass an FD to a subprocess.
+ */
+ static ChildHook UNSET_CLOEXEC(int fd);
#endif // __WINDOWS__
/**
http://git-wip-us.apache.org/repos/asf/mesos/blob/46be1e80/3rdparty/libprocess/src/subprocess.cpp
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/src/subprocess.cpp b/3rdparty/libprocess/src/subprocess.cpp
index 340fc32..ad19b08 100644
--- a/3rdparty/libprocess/src/subprocess.cpp
+++ b/3rdparty/libprocess/src/subprocess.cpp
@@ -98,6 +98,14 @@ Subprocess::ChildHook Subprocess::ChildHook::DUP2(int oldFd, int newFd)
return os::dup2(oldFd, newFd);
});
}
+
+
+Subprocess::ChildHook Subprocess::ChildHook::UNSET_CLOEXEC(int fd)
+{
+ return Subprocess::ChildHook([fd]() -> Try<Nothing> {
+ return os::unsetCloexec(fd);
+ });
+}
#endif // __WINDOWS__