Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Don't qwack when the default empty string is passed as a replay path
[simgrid.git] / src / kernel / EngineImpl.cpp
index 025228ae6e445d65ec620254ad8c2c4e1878d7a8..a5b2d5718ef51e1437f152c89c7362f178f1a674 100644 (file)
 #include "src/simgrid/math_utils.h"
 #include "src/simgrid/sg_config.hpp"
 #include "src/smpi/include/smpi_actor.hpp"
-#include "src/xbt/xbt_modinter.h" /* whether initialization was already done */
+
+#if SIMGRID_HAVE_MC
+#include "src/mc/remote/AppSide.hpp"
+#endif
 
 #include "xbt/log.hpp"
 
 #include <boost/algorithm/string/predicate.hpp>
 #include <dlfcn.h>
 
-#if SIMGRID_HAVE_MC
-#include "src/mc/remote/AppSide.hpp"
-#endif
-
 XBT_LOG_NEW_DEFAULT_CATEGORY(ker_engine, "Logging specific to Engine (kernel)");
 
 namespace simgrid::kernel {
@@ -142,12 +141,6 @@ static void install_signal_handlers()
 
 static simgrid::config::Flag<bool> cfg_dbg_clean_atexit{
     "debug/clean-atexit", "Whether to cleanup SimGrid at exit. Disable it if your code segfaults after its end.", true};
-static void xbt_postexit()
-{
-  if (not cfg_dbg_clean_atexit)
-    return;
-  xbt_log_postexit();
-}
 
 namespace simgrid::kernel {
 
@@ -182,25 +175,20 @@ void EngineImpl::initialize(int* argc, char** argv)
   // The communication initialization is done ASAP, as we need to get some init parameters from the MC for different
   // layers. But instance_ needs to be created, as we send the address of some of its fields to the MC that wants to
   // read them directly.
-  simgrid::mc::AppSide::initialize();
+  simgrid::mc::AppSide::get(); // To ensure that it's initialized
 #endif
 
-  static bool inited = false;
-  if (not inited) {
+  if (static bool inited = false; not inited) {
     inited = true;
-    atexit(xbt_postexit);
     xbt_log_init(argc, argv);
 
     simgrid::xbt::install_exception_handler();
 
-    if (*argc > 0)
-      simgrid::xbt::binary_name = argv[0];
-    for (int i = 0; i < *argc; i++)
-      simgrid::xbt::cmdline.emplace_back(argv[i]);
-
     sg_config_init(argc, argv);
   }
 
+  cmdline_.assign(argv, argv + *argc);
+
   instance_->context_mod_init();
 
   install_signal_handlers();
@@ -374,7 +362,7 @@ void EngineImpl::handle_ended_actions() const
         if (action->get_activity()->get_actor() == maestro_)
           action->get_activity()->get_iface()->complete(s4u::Activity::State::FAILED);
 
-        activity::ActivityImplPtr(action->get_activity())->post();
+        activity::ActivityImplPtr(action->get_activity())->finish();
       }
     }
     XBT_DEBUG("Handling the terminated actions (if any)");
@@ -387,7 +375,7 @@ void EngineImpl::handle_ended_actions() const
         if (action->get_activity()->get_actor() == maestro_)
           action->get_activity()->get_iface()->complete(s4u::Activity::State::FINISHED);
 
-        activity::ActivityImplPtr(action->get_activity())->post();
+        activity::ActivityImplPtr(action->get_activity())->finish();
       }
     }
   }