Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Only fire on_platform_created after creating the platform, not after loading the...
authorMartin Quinson <martin.quinson@ens-rennes.fr>
Sun, 16 Apr 2023 10:23:18 +0000 (12:23 +0200)
committerMartin Quinson <martin.quinson@ens-rennes.fr>
Sun, 16 Apr 2023 10:23:18 +0000 (12:23 +0200)
src/kernel/EngineImpl.cpp
src/kernel/resource/models/network_ns3.cpp
src/kernel/xml/platf.hpp
src/kernel/xml/platf_sax_cb.cpp
src/kernel/xml/sg_platf.cpp

index 377f2b5..c72b299 100644 (file)
@@ -324,7 +324,7 @@ void EngineImpl::load_deployment(const std::string& file) const
   sg_platf_parser_finalize();
 
   simgrid_parse_open(file);
-  simgrid_parse();
+  simgrid_parse(false);
   simgrid_parse_close();
 }
 
index 28519c8..b493267 100644 (file)
@@ -341,7 +341,7 @@ NetworkNS3Model::NetworkNS3Model(const std::string& name) : NetworkModel(name)
 
   s4u::Engine::on_platform_created_cb([]() {
     /* Create the ns3 topology based on routing strategy */
-    ns3::GlobalRouteManager::DeleteGlobalRoutes(); // just in case this callback is called twice
+    xbt_assert(not ns3_is_initialized, "ns-3 initialized twice.");
     ns3::GlobalRouteManager::BuildGlobalRoutingDatabase();
     ns3::GlobalRouteManager::InitializeRoutes();
     ns3_is_initialized = true;
index 79374c1..9e3d355 100644 (file)
@@ -23,7 +23,7 @@ XBT_PUBLIC void simgrid_parse_assert_netpoint(const std::string& hostname, const
 XBT_PUBLIC double simgrid_parse_get_double(const std::string& s);
 XBT_PUBLIC int simgrid_parse_get_int(const std::string& s);
 
-XBT_PUBLIC void simgrid_parse(); /* Entry-point to the parser */
+XBT_PUBLIC void simgrid_parse(bool fire_on_platform_created_callback); /* Entry-point to the parser */
 XBT_PUBLIC void parse_platform_file(const std::string& file);
 
 #endif
index df5b5cc..23528c0 100644 (file)
@@ -31,6 +31,8 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(platf_parse, ker_platform, "Logging specific to
 std::string simgrid_parsed_filename;                            // Currently parsed file (for the error messages)
 static std::vector<simgrid::s4u::LinkInRoute> parsed_link_list; /* temporary store of current link list of a route */
 
+static bool fire_on_platform_created_callback;
+
 /* Helping functions */
 void simgrid_parse_assert(bool cond, const std::string& msg)
 {
@@ -259,7 +261,8 @@ void STag_simgrid_parse_platform()
 }
 void ETag_simgrid_parse_platform()
 {
-  simgrid::s4u::Engine::on_platform_created();
+  if (fire_on_platform_created_callback)
+    simgrid::s4u::Engine::on_platform_created();
 }
 
 void STag_simgrid_parse_prop()
@@ -947,8 +950,9 @@ void simgrid_parse_close()
 }
 
 /* Call the lexer to parse the currently opened file */
-void simgrid_parse()
+void simgrid_parse(bool fire_on_platform_created_callback_param)
 {
+  fire_on_platform_created_callback = fire_on_platform_created_callback_param;
   bool err = simgrid_parse_lex();
   simgrid_parse_assert(not err, "Flex returned an error code");
 
index 888944a..1b2055d 100644 (file)
@@ -40,7 +40,7 @@ void parse_platform_file(const std::string& file)
   simgrid_parse_open(file);
 
   /* Do the actual parsing */
-  simgrid_parse();
+  simgrid_parse(true);
 
   simgrid_parse_close();
 }