Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
remove completely the energy concern from the core
[simgrid.git] / src / mc / mc_client.cpp
index 9caade7..3956391 100644 (file)
@@ -8,20 +8,21 @@
 #include <cerrno>
 
 #include <sys/types.h>
+#include <sys/ptrace.h>
 #include <sys/socket.h>
 
 #include <xbt/log.h>
 #include <xbt/sysdep.h>
 #include <xbt/mmalloc.h>
 
-#include "mc_protocol.h"
-#include "mc_client.h"
+#include "src/mc/mc_protocol.h"
+#include "src/mc/mc_client.h"
 
 // We won't need those once the separation MCer/MCed is complete:
-#include "mc_mmalloc.h"
-#include "mc_ignore.h"
-#include "mc_private.h" // MC_deadlock_check()
-#include "mc_smx.h"
+#include "src/mc/mc_mmalloc.h"
+#include "src/mc/mc_ignore.h"
+#include "src/mc/mc_private.h" // MC_deadlock_check()
+#include "src/mc/mc_smx.h"
 
 extern "C" {
 
@@ -31,6 +32,12 @@ mc_client_t mc_client;
 
 void MC_client_init(void)
 {
+  if (mc_mode != MC_MODE_NONE)
+    return;
+  if (!getenv(MC_ENV_SOCKET_FD))
+    return;
+  mc_mode = MC_MODE_CLIENT;
+
   if (mc_client) {
     XBT_WARN("MC_client_init called more than once.");
     return;
@@ -54,6 +61,11 @@ void MC_client_init(void)
   mc_client = xbt_new0(s_mc_client_t, 1);
   mc_client->fd = fd;
   mc_client->active = 1;
+
+  // Waiting for the model-checker:
+  if (ptrace(PTRACE_TRACEME, 0, NULL, NULL) == -1 || raise(SIGSTOP) != 0)
+    xbt_die("Could not wait for the model-checker");
+  MC_client_handle_messages();
 }
 
 void MC_client_send_message(void* message, size_t size)