From 9f56ed220cda230775eba337d021346c01ae37b8 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Sun, 16 Jul 2017 18:22:42 +0200 Subject: [PATCH] further cleanups of the MC protocol (and fix its build :) --- src/mc/ModelChecker.cpp | 4 ++-- src/mc/ModelChecker.hpp | 6 +----- src/mc/Session.cpp | 2 +- src/mc/mc_unw.h | 2 ++ src/mc/remote/Client.cpp | 12 ++++++------ src/mc/remote/Client.hpp | 4 ++-- 6 files changed, 14 insertions(+), 16 deletions(-) diff --git a/src/mc/ModelChecker.cpp b/src/mc/ModelChecker.cpp index 339d6377a5..855c0a7128 100644 --- a/src/mc/ModelChecker.cpp +++ b/src/mc/ModelChecker.cpp @@ -387,9 +387,9 @@ void ModelChecker::on_signal(int signo) } } -void ModelChecker::wait_client(simgrid::mc::RemoteClient& process) +void ModelChecker::wait_for_requests() { - this->resume(process); + this->resume(process()); if (this->process().running()) event_base_dispatch(base_); } diff --git a/src/mc/ModelChecker.hpp b/src/mc/ModelChecker.hpp index 95543458ec..bb733e3e61 100644 --- a/src/mc/ModelChecker.hpp +++ b/src/mc/ModelChecker.hpp @@ -69,12 +69,8 @@ public: void resume(simgrid::mc::RemoteClient& process); void loop(); void handle_events(int fd, short events); - void wait_client(simgrid::mc::RemoteClient& process); + void wait_for_requests(); void handle_simcall(Transition const& transition); - void wait_for_requests() - { - mc_model_checker->wait_client(mc_model_checker->process()); - } void exit(int status); bool checkDeadlock(); diff --git a/src/mc/Session.cpp b/src/mc/Session.cpp index 84a2105e51..566858b8ad 100644 --- a/src/mc/Session.cpp +++ b/src/mc/Session.cpp @@ -136,7 +136,7 @@ void Session::logState() Session* Session::fork(std::function code) { // Create a AF_LOCAL socketpair used for exchanging messages - // bewteen the model-checker process (ourselves) and the model-checked + // between the model-checker process (ourselves) and the model-checked // process: int res; int sockets[2]; diff --git a/src/mc/mc_unw.h b/src/mc/mc_unw.h index 8227402c38..6a6b861a17 100644 --- a/src/mc/mc_unw.h +++ b/src/mc/mc_unw.h @@ -26,8 +26,10 @@ */ #include "src/mc/mc_forward.hpp" +#include "xbt/base.h" #include +#include #include namespace simgrid { diff --git a/src/mc/remote/Client.cpp b/src/mc/remote/Client.cpp index 2962c8f547..8eaa9f96ca 100644 --- a/src/mc/remote/Client.cpp +++ b/src/mc/remote/Client.cpp @@ -33,7 +33,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_client, mc, "MC client logic"); namespace simgrid { namespace mc { -std::unique_ptr Client::client_; +std::unique_ptr Client::instance_; Client* Client::initialize() { @@ -43,8 +43,8 @@ Client* Client::initialize() return nullptr; // Do not break if we are called multiple times: - if (client_) - return client_.get(); + if (instance_) + return instance_.get(); _sg_do_model_check = 1; @@ -65,7 +65,7 @@ Client* Client::initialize() xbt_die("Unexpected socket type %i", type); XBT_DEBUG("Model-checked application found expected socket type"); - client_ = std::unique_ptr(new simgrid::mc::Client(fd)); + instance_ = std::unique_ptr(new simgrid::mc::Client(fd)); // Wait for the model-checker: errno = 0; @@ -79,8 +79,8 @@ Client* Client::initialize() if (errno != 0 || raise(SIGSTOP) != 0) xbt_die("Could not wait for the model-checker"); - client_->handleMessages(); - return client_.get(); + instance_->handleMessages(); + return instance_.get(); } void Client::handleDeadlockCheck(mc_message_t* msg) diff --git a/src/mc/remote/Client.hpp b/src/mc/remote/Client.hpp index 149140e46f..b9059a3229 100644 --- a/src/mc/remote/Client.hpp +++ b/src/mc/remote/Client.hpp @@ -30,7 +30,7 @@ class XBT_PUBLIC() Client { private: bool active_ = false; Channel channel_; - static std::unique_ptr client_; + static std::unique_ptr instance_; public: Client(); @@ -59,7 +59,7 @@ public: // Singleton :/ // TODO, remove the singleton antipattern. static Client* initialize(); - static Client* get() { return client_.get(); } + static Client* get() { return instance_.get(); } }; } } -- 2.20.1