Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
[mc] Fix previous commit
authorGabriel Corona <gabriel.corona@loria.fr>
Fri, 26 Feb 2016 11:36:50 +0000 (12:36 +0100)
committerGabriel Corona <gabriel.corona@loria.fr>
Fri, 26 Feb 2016 11:36:50 +0000 (12:36 +0100)
It was completely broken :/

include/xbt/system_error.hpp
src/mc/ModelChecker.cpp
src/mc/simgrid_mc.cpp

index 02f5089..f2aabe7 100644 (file)
@@ -18,13 +18,13 @@ const std::error_category& errno_category() noexcept
 }
 
 inline
 }
 
 inline
-std::system_error errno_error(int errnum) noexcept
+std::system_error errno_error(int errnum)
 {
   return std::system_error(errnum, errno_category());
 }
 
 inline
 {
   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);
 }
 {
   return std::system_error(errnum, errno_category(), what);
 }
index da9a245..9289500 100644 (file)
@@ -308,7 +308,7 @@ bool ModelChecker::handle_events()
     case EINTR:
       continue;
     default:
     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)
     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) {
       return handle_message(buffer, size);
     }
     if (socket_pollfd->revents & POLLERR) {
@@ -357,7 +357,7 @@ void ModelChecker::handle_signals()
       if (errno == EINTR)
         continue;
       else
       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");
     } 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");
           break;
       } else {
         XBT_ERROR("Could not wait for pid");
-        throw simgrid::mc::errno_error(errno);
+        throw simgrid::xbt::errno_error(errno);
       }
     }
 
       }
     }
 
index 99a6abd..a5dbc31 100644 (file)
@@ -27,6 +27,7 @@
 #endif
 
 #include <xbt/log.h>
 #endif
 
 #include <xbt/log.h>
+#include <xbt/system_error.hpp>
 
 #include "simgrid/sg_config.h"
 #include "src/xbt_modinter.h"
 
 #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)
 {
   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;
 
   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)
   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)
   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;
 #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)
   // 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);
 
   // Set environment:
   setenv(MC_ENV_VARIABLE, "1", 1);
@@ -116,7 +117,7 @@ std::pair<pid_t, int> create_model_checked(char** argv)
   int sockets[2];
   res = socketpair(AF_LOCAL, SOCK_DGRAM | SOCK_CLOEXEC, 0, sockets);
   if (res == -1)
   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]);
 
   pid_t pid = do_fork([&] {
     close(sockets[1]);