From 28f07de780131679dffc1443e213ae7a549bd601 Mon Sep 17 00:00:00 2001 From: Gabriel Corona Date: Fri, 26 Feb 2016 12:36:50 +0100 Subject: [PATCH] [mc] Fix previous commit It was completely broken :/ --- include/xbt/system_error.hpp | 4 ++-- src/mc/ModelChecker.cpp | 8 ++++---- src/mc/simgrid_mc.cpp | 11 ++++++----- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/include/xbt/system_error.hpp b/include/xbt/system_error.hpp index 02f508990e..f2aabe7f83 100644 --- a/include/xbt/system_error.hpp +++ b/include/xbt/system_error.hpp @@ -18,13 +18,13 @@ const std::error_category& errno_category() noexcept } inline -std::system_error errno_error(int errnum) noexcept +std::system_error errno_error(int errnum) { return std::system_error(errnum, errno_category()); } inline -std::system_error errno_error(int errno, const char* what) +std::system_error errno_error(int errnum, const char* what) { return std::system_error(errnum, errno_category(), what); } diff --git a/src/mc/ModelChecker.cpp b/src/mc/ModelChecker.cpp index da9a2451af..92895002f4 100644 --- a/src/mc/ModelChecker.cpp +++ b/src/mc/ModelChecker.cpp @@ -308,7 +308,7 @@ bool ModelChecker::handle_events() case EINTR: continue; default: - throw simgrid::mc::errno_error(errno); + throw simgrid::xbt::errno_error(errno); } } @@ -316,7 +316,7 @@ bool ModelChecker::handle_events() if (socket_pollfd->revents & POLLIN) { ssize_t size = MC_receive_message(socket_pollfd->fd, buffer, sizeof(buffer), MSG_DONTWAIT); if (size == -1 && errno != EAGAIN) - throw simgrid::mc::errno_error(errno); + throw simgrid::xbt::errno_error(errno); return handle_message(buffer, size); } if (socket_pollfd->revents & POLLERR) { @@ -357,7 +357,7 @@ void ModelChecker::handle_signals() if (errno == EINTR) continue; else - throw simgrid::mc::errno_error(errno); + throw simgrid::xbt::errno_error(errno); } else if (size != sizeof(info)) return throw std::runtime_error( "Bad communication with model-checked application"); @@ -382,7 +382,7 @@ void ModelChecker::handle_waitpid() break; } else { XBT_ERROR("Could not wait for pid"); - throw simgrid::mc::errno_error(errno); + throw simgrid::xbt::errno_error(errno); } } diff --git a/src/mc/simgrid_mc.cpp b/src/mc/simgrid_mc.cpp index 99a6abdc7e..a5dbc3178c 100644 --- a/src/mc/simgrid_mc.cpp +++ b/src/mc/simgrid_mc.cpp @@ -27,6 +27,7 @@ #endif #include +#include #include "simgrid/sg_config.h" #include "src/xbt_modinter.h" @@ -48,7 +49,7 @@ pid_t do_fork(F f) { pid_t pid = fork(); if (pid < 0) - throw simgrid::mc::errno_error(errno, "Could not fork model-checked process"); + throw simgrid::xbt::errno_error(errno, "Could not fork model-checked process"); if (pid != 0) return pid; @@ -73,9 +74,9 @@ int exec_model_checked(int socket, char** argv) sigset_t mask; sigemptyset (&mask); if (sigprocmask(SIG_SETMASK, &mask, nullptr) < 0) - throw simgrid::mc::errno_error(errno, "Could not unblock signals"); + throw simgrid::xbt::errno_error(errno, "Could not unblock signals"); if (prctl(PR_SET_PDEATHSIG, SIGHUP) != 0) - throw simgrid::mc::errno_error(errno, "Could not PR_SET_PDEATHSIG"); + throw simgrid::xbt::errno_error(errno, "Could not PR_SET_PDEATHSIG"); #endif int res; @@ -83,7 +84,7 @@ int exec_model_checked(int socket, char** argv) // Remove CLOEXEC in order to pass the socket to the exec-ed program: int fdflags = fcntl(socket, F_GETFD, 0); if (fdflags == -1 || fcntl(socket, F_SETFD, fdflags & ~FD_CLOEXEC) == -1) - throw simgrid::xbt::system_error(errno, "Could not remove CLOEXEC for socket"); + throw simgrid::xbt::errno_error(errno, "Could not remove CLOEXEC for socket"); // Set environment: setenv(MC_ENV_VARIABLE, "1", 1); @@ -116,7 +117,7 @@ std::pair create_model_checked(char** argv) int sockets[2]; res = socketpair(AF_LOCAL, SOCK_DGRAM | SOCK_CLOEXEC, 0, sockets); if (res == -1) - throw simgrid::xbt::system_error(errno, "Could not create socketpair"); + throw simgrid::xbt::errno_error(errno, "Could not create socketpair"); pid_t pid = do_fork([&] { close(sockets[1]); -- 2.20.1