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:37 UTC
[3/3] mesos git commit: Used UNSET_CLOEXEC instead of DUP2 hook for
I/O switchboard.
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",