Agent: Added Windows support for `launch.cpp`. Review: https://reviews.apache.org/r/47469/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/e182780d Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/e182780d Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/e182780d Branch: refs/heads/master Commit: e182780dc52622d640fa4653bd263026e941120c Parents: 5239702 Author: Alex Clemmer <[email protected]> Authored: Mon May 30 20:52:24 2016 -0700 Committer: Joris Van Remoortere <[email protected]> Committed: Mon May 30 20:59:13 2016 -0700 ---------------------------------------------------------------------- src/CMakeLists.txt | 2 +- src/slave/containerizer/mesos/launch.cpp | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/e182780d/src/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 577a17c..1a0c447 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -265,6 +265,7 @@ set(AGENT_SRC slave/state.cpp slave/status_update_manager.cpp slave/validation.cpp + slave/containerizer/mesos/launch.cpp ) if (NOT WIN32) @@ -283,7 +284,6 @@ if (NOT WIN32) slave/containerizer/fetcher.cpp slave/containerizer/mesos/containerizer.cpp slave/containerizer/mesos/isolator.cpp - slave/containerizer/mesos/launch.cpp slave/containerizer/mesos/launcher.cpp slave/containerizer/mesos/mount.cpp slave/containerizer/mesos/isolators/filesystem/posix.cpp http://git-wip-us.apache.org/repos/asf/mesos/blob/e182780d/src/slave/containerizer/mesos/launch.cpp ---------------------------------------------------------------------- diff --git a/src/slave/containerizer/mesos/launch.cpp b/src/slave/containerizer/mesos/launch.cpp index e22106b..636921c 100644 --- a/src/slave/containerizer/mesos/launch.cpp +++ b/src/slave/containerizer/mesos/launch.cpp @@ -133,7 +133,18 @@ int MesosContainerizerLaunch::execute() } } - Try<Nothing> close = os::close(flags.pipe_write.get()); + int pipe[2] = { flags.pipe_read.get(), flags.pipe_write.get() }; + +// NOTE: On windows we need to pass `HANDLE`s between processes, as +// file descriptors are not unique across processes. Here we convert +// back from from the `HANDLE`s we receive to fds that can be used in +// os-agnostic code. +#ifdef __WINDOWS__ + pipe[0] = os::handle_to_fd(pipe[0], _O_RDONLY | _O_TEXT); + pipe[1] = os::handle_to_fd(pipe[1], _O_TEXT); +#endif // __WINDOWS__ + + Try<Nothing> close = os::close(pipe[1]); if (close.isError()) { cerr << "Failed to close pipe[1]: " << close.error() << endl; return 1; @@ -142,8 +153,8 @@ int MesosContainerizerLaunch::execute() // Do a blocking read on the pipe until the parent signals us to continue. char dummy; ssize_t length; - while ((length = ::read( - flags.pipe_read.get(), + while ((length = os::read( + pipe[0], &dummy, sizeof(dummy))) == -1 && errno == EINTR); @@ -155,7 +166,7 @@ int MesosContainerizerLaunch::execute() return 1; } - close = os::close(flags.pipe_read.get()); + close = os::close(pipe[0]); if (close.isError()) { cerr << "Failed to close pipe[0]: " << close.error() << endl; return 1;
