X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/69f8eb4aea98b46c7df3ca9a44bf46fc1ba2348b..fa40abdc1d0705869a181ee3f2e9be45325d4e25:/src/mc/Session.cpp diff --git a/src/mc/Session.cpp b/src/mc/Session.cpp index 04d40a0eb0..f8d8819460 100644 --- a/src/mc/Session.cpp +++ b/src/mc/Session.cpp @@ -15,6 +15,9 @@ #include "xbt/log.h" #include "xbt/system_error.hpp" +#include +#include + #include #ifdef __linux__ #include @@ -25,7 +28,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_Session, mc, "Model-checker session"); namespace simgrid { namespace mc { -static void run_child_process(int socket, const std::function& code) +template void run_child_process(int socket, Code code) { /* On startup, simix_global_init() calls simgrid::mc::Client::initialize(), which checks whether the MC_ENV_SOCKET_FD * env variable is set. If so, MC mode is assumed, and the client is setup from its side @@ -48,10 +51,7 @@ static void run_child_process(int socket, const std::function& code) // modifying its .got.plt during snapshot. setenv("LC_BIND_NOW", "1", 1); - char buffer[64]; - int res = std::snprintf(buffer, sizeof(buffer), "%i", socket); - xbt_assert((size_t)res < sizeof(buffer) && res != -1); - setenv(MC_ENV_SOCKET_FD, buffer, 1); + setenv(MC_ENV_SOCKET_FD, std::to_string(socket).c_str(), 1); code(); } @@ -64,7 +64,7 @@ Session::Session(const std::function& code) "Please use the dlopen privatization schema when model-checking SMPI code"); #endif - // Create a AF_LOCAL socketpair used for exchanging messages + // Create an AF_LOCAL socketpair used for exchanging messages // between the model-checker process (ourselves) and the model-checked // process: int sockets[2]; @@ -86,7 +86,7 @@ Session::Session(const std::function& code) xbt_assert(mc_model_checker == nullptr, "Did you manage to start the MC twice in this process?"); auto process = std::make_unique(pid); - model_checker_.reset(new simgrid::mc::ModelChecker(std::move(process), sockets[1])); + model_checker_ = std::make_unique(std::move(process), sockets[1]); mc_model_checker = model_checker_.get(); model_checker_->start();