Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Have the application execute its transition before returning SIMCALL_EXECUTE_ANSWER
[simgrid.git] / src / mc / remote / AppSide.cpp
index e0026c06af2bd4b43258341ffbb244d5502ff667..e56a85476db8ffc012f16b825a05250169865e11 100644 (file)
@@ -99,29 +99,30 @@ void AppSide::handle_simcall_execute(const s_mc_message_simcall_execute_t* messa
   kernel::actor::ActorImpl* actor = kernel::actor::ActorImpl::by_pid(message->aid_);
   xbt_assert(actor != nullptr, "Invalid pid %ld", message->aid_);
 
+  // The client may send some messages to the server while processing the transition
+  actor->simcall_handle(message->times_considered_);
+  // Say the server that the transition is over and that it should proceed
+  xbt_assert(channel_.send(MessageType::WAITING) == 0, "Could not send MESSAGE_WAITING to model-checker");
+
   // Finish the RPC from the server: return a serialized observer, to build a Transition on Checker side
   s_mc_message_simcall_execute_answer_t answer;
   memset(&answer, 0, sizeof(answer));
   answer.type = MessageType::SIMCALL_EXECUTE_ANSWER;
+  std::stringstream stream;
   if (actor->simcall_.observer_ != nullptr) {
-    std::stringstream stream;
-    actor->simcall_.observer_->serialize(answer.simcall, stream);
-    xbt_assert(stream.str().size() < sizeof(answer.buffer),
-               "The serialized simcall is too large for the buffer. Please fix the code.");
-    strncpy(answer.buffer, stream.str().c_str(), SIMCALL_SERIALIZATION_BUFFER_SIZE);
+    actor->simcall_.observer_->serialize(stream);
   } else {
-    answer.simcall = kernel::actor::SimcallObserver::Simcall::UNKNOWN;
+    stream << (short)mc::Transition::Type::UNKNOWN;
   }
+  std::string str = stream.str();
+  xbt_assert(str.size() + 1 <= answer.buffer.size(),
+             "The serialized simcall is too large for the buffer. Please fix the code.");
+  strncpy(answer.buffer.data(), str.c_str(), answer.buffer.size() - 1);
+  answer.buffer.back() = '\0';
 
-  XBT_DEBUG("send SIMCALL_EXECUTE_ANSWER(%s) ~> %s '%s'", actor->get_cname(),
-            simgrid::kernel::actor::SimcallObserver::to_c_str(answer.simcall), answer.buffer);
+  XBT_DEBUG("send SIMCALL_EXECUTE_ANSWER(%s) ~> '%s'", actor->get_cname(), str.c_str());
   xbt_assert(channel_.send(answer) == 0, "Could not send response");
 
-  // The client may send some messages to the server while processing the transition
-  actor->simcall_handle(message->times_considered_);
-
-  // Say the server that the transition is over and that it should proceed
-  xbt_assert(channel_.send(MessageType::WAITING) == 0, "Could not send MESSAGE_WAITING to model-checker");
 }
 
 void AppSide::handle_actor_enabled(const s_mc_message_actor_enabled_t* msg) const
@@ -176,24 +177,6 @@ void AppSide::handle_messages() const
         break;
       }
 
-      case MessageType::SIMCALL_DOT_LABEL: {
-        assert_msg_size("SIMCALL_DOT_LABEL", s_mc_message_simcall_to_string_t);
-        auto msg_simcall                      = (s_mc_message_simcall_to_string_t*)message_buffer.data();
-        const kernel::actor::ActorImpl* actor = kernel::actor::ActorImpl::by_pid(msg_simcall->aid);
-        xbt_assert(actor != nullptr, "Invalid pid %ld", msg_simcall->aid);
-        std::string value = "";
-        if (actor->simcall_.observer_ != nullptr)
-          value = actor->simcall_.observer_->dot_label(msg_simcall->time_considered);
-        else
-          value = "UNIMPLEMENTED";
-
-        // Send result:
-        s_mc_message_simcall_to_string_answer_t answer{MessageType::SIMCALL_DOT_LABEL_ANSWER, {0}};
-        value.copy(answer.value, (sizeof answer.value) - 1); // last byte was set to '\0' by initialization above
-        xbt_assert(channel_.send(answer) == 0, "Could not send response");
-        break;
-      }
-
       case MessageType::ACTOR_ENABLED:
         assert_msg_size("ACTOR_ENABLED", s_mc_message_actor_enabled_t);
         handle_actor_enabled((s_mc_message_actor_enabled_t*)message_buffer.data());