Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cleanup the way surf_parse_models_setup is called after the last <config> and before...
authorMartin Quinson <martin.quinson@loria.fr>
Thu, 3 Nov 2011 14:15:13 +0000 (15:15 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Thu, 3 Nov 2011 14:15:13 +0000 (15:15 +0100)
src/surf/surf_routing.c
src/surf/surfxml_parse.c

index e7f700f..a0df3bb 100644 (file)
@@ -992,14 +992,19 @@ void surf_parse_add_callback_config(void)
        surfxml_add_callback(STag_surfxml_config_cb_list, &routing_parse_Sconfig);
        surfxml_add_callback(ETag_surfxml_config_cb_list, &routing_parse_Econfig);
        surfxml_add_callback(STag_surfxml_prop_cb_list, &parse_properties_XML);
-       surfxml_add_callback(STag_surfxml_AS_cb_list, &surf_parse_models_setup);
        surfxml_add_callback(STag_surfxml_random_cb_list, &routing_parse_Srandom);
 }
 
+/* Call the last initialization functions, that must be called after the
+ * <config> tag, if any, and before the first of cluster|peer|AS|trace|trace_connect
+ */
 void surf_parse_models_setup()
 {
+  static int already_called=0;
+  if (already_called)
+    return;
+  already_called=1;
        routing_parse_Erandom();
-       surfxml_del_callback(STag_surfxml_AS_cb_list, surf_parse_models_setup);
        surf_config_models_setup();
 }
 
@@ -1480,7 +1485,7 @@ static void routing_parse_Econfig(void)
          if(xbt_cfg_is_default_value(_surf_cfg_set, key))
                  xbt_cfg_set_parse(_surf_cfg_set, cfg);
          else
-                 XBT_INFO("The custom configuration '%s' is already define by user!",key);
+                 XBT_INFO("The custom configuration '%s' is already defined by user!",key);
          free(cfg);
   }
   XBT_DEBUG("End configuration name = %s",A_surfxml_config_id);
@@ -2097,17 +2102,16 @@ static void routing_parse_Srandom(void)
 
 static void routing_parse_Erandom(void)
 {
-       xbt_dict_cursor_t cursor = NULL;
+       /*xbt_dict_cursor_t cursor = NULL;
        char *key;
        char *elem;
 
        xbt_dict_foreach(random_value, cursor, key, elem) {
          XBT_DEBUG("%s = %s",key,elem);
        }
-
+*/
 }
 
-
 /*
  * New methods to init the routing model component from the lua script
  */
index 6337923..8889e75 100644 (file)
@@ -475,6 +475,8 @@ void STag_surfxml_trace_connect(void){
        surfxml_call_cb_functions(STag_surfxml_trace_connect_cb_list);
 }
 void STag_surfxml_AS(void){
+  surf_parse_models_setup(); /* ensure that the models are created after the last <config> tag. See comment in simgrid.dtd */
+
        surfxml_call_cb_functions(STag_surfxml_AS_cb_list);
 }
 void STag_surfxml_ASroute(void){