This is an automated email from the ASF dual-hosted git repository. jbarrett pushed a commit to branch develop in repository https://gitbox.apache.org/repos/asf/geode-native.git
The following commit(s) were added to refs/heads/develop by this push: new d61a403 GEODE-5037: Fixes gfsh execution d61a403 is described below commit d61a403a7507e1dc873c7d65a8b19c66ab1eb3db Author: Jacob Barrett <jbarr...@pivotal.io> AuthorDate: Tue Apr 10 03:28:35 2018 +0000 GEODE-5037: Fixes gfsh execution - synchronize starting of child process on windows. --- cppcache/integration-test-2/framework/Cluster.cpp | 2 ++ .../integration-test-2/framework/GfshExecute.cpp | 41 ++++++++++++++++------ .../integration-test-2/framework/GfshExecute.h | 6 +++- 3 files changed, 38 insertions(+), 11 deletions(-) diff --git a/cppcache/integration-test-2/framework/Cluster.cpp b/cppcache/integration-test-2/framework/Cluster.cpp index 3f131dd..5f7490a 100644 --- a/cppcache/integration-test-2/framework/Cluster.cpp +++ b/cppcache/integration-test-2/framework/Cluster.cpp @@ -17,6 +17,8 @@ #include "Cluster.h" +#include <future> + void Locator::start() { if (started_) return; diff --git a/cppcache/integration-test-2/framework/GfshExecute.cpp b/cppcache/integration-test-2/framework/GfshExecute.cpp index 4309e43..fb9eb61 100644 --- a/cppcache/integration-test-2/framework/GfshExecute.cpp +++ b/cppcache/integration-test-2/framework/GfshExecute.cpp @@ -17,6 +17,14 @@ #include "GfshExecute.h" +#include <mutex> + +#include <boost/log/trivial.hpp> + +#if defined(_WINDOWS) +std::mutex g_child_mutex; +#endif + void GfshExecute::execute(const std::string &command) { BOOST_LOG_TRIVIAL(info) << "Gfsh::execute: " << command; @@ -33,21 +41,34 @@ void GfshExecute::execute(const std::string &command) { auto env = boost::this_process::environment(); // broken on windows env["JAVA_ARGS"] = "-Xmx1g -client"; - // pipes broken on windows. - // ipstream outStream; - // ipstream errStream; - child gfsh(GFSH_EXECUTABLE, args = commands, env, std_out > null, - std_err > null, std_in < null); + ipstream outStream; + ipstream errStream; - // std::string line; + auto gfsh = executeChild(commands, env, outStream, errStream); - // while (outStream && std::getline(outStream, line) && !line.empty()) - // BOOST_LOG_TRIVIAL(debug) << "Gfsh::execute: " << line; + std::string line; - // while (errStream && std::getline(errStream, line) && !line.empty()) - // BOOST_LOG_TRIVIAL(error) << "Gfsh::execute: " << line; + while (outStream && std::getline(outStream, line) && !line.empty()) + BOOST_LOG_TRIVIAL(debug) << "Gfsh::execute: " << line; + + while (errStream && std::getline(errStream, line) && !line.empty()) + BOOST_LOG_TRIVIAL(error) << "Gfsh::execute: " << line; gfsh.wait(); extractConnectionCommand(command); } + +boost::process::child GfshExecute::executeChild( + std::vector<std::string> &commands, boost::process::native_environment &env, + boost::process::ipstream &outStream, boost::process::ipstream &errStream) { + using namespace boost::process; + +#if defined(_WINDOWS) + // https://github.com/klemens-morgenstern/boost-process/issues/159 + std::lock_guard<std::mutex> guard(g_child_mutex); +#endif + + return child(GFSH_EXECUTABLE, args = commands, env, std_out > outStream, + std_err > errStream, std_in < null); +} diff --git a/cppcache/integration-test-2/framework/GfshExecute.h b/cppcache/integration-test-2/framework/GfshExecute.h index 83144ca..2edda39 100644 --- a/cppcache/integration-test-2/framework/GfshExecute.h +++ b/cppcache/integration-test-2/framework/GfshExecute.h @@ -30,7 +30,6 @@ #include <boost/process.hpp> #pragma error_messages(on, oklambdaretmulti, wvarhidemem, \ w_constexprnonlitret, explctspectypename) -#include <boost/log/trivial.hpp> #include "Gfsh.h" #include "config.h" @@ -59,6 +58,11 @@ class GfshExecute : public Gfsh { protected: void execute(const std::string &command) override; + boost::process::child executeChild(std::vector<std::string> &commands, + boost::process::native_environment &env, + boost::process::ipstream &outStream, + boost::process::ipstream &errStream); + void extractConnectionCommand(const std::string &command) { if (starts_with(command, std::string("connect"))) { connection_ = command; -- To stop receiving notification emails like this one, please contact jbarr...@apache.org.