From 035063bc298e061d8f47cc49f63311451d681af7 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Thu, 3 Nov 2011 18:11:24 +0100 Subject: [PATCH] damn. Make sure that the models are inited only once when parsing the same file twice, while ensuring that it still work when parsing after a SD_exit()/SD_init() reset (we have vicious test cases, of which 10 are still broken) --- src/surf/surf_routing.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/surf/surf_routing.c b/src/surf/surf_routing.c index 25f4fa6b59..78d9f4667e 100644 --- a/src/surf/surf_routing.c +++ b/src/surf/surf_routing.c @@ -833,6 +833,20 @@ static double get_latency(const char *src, const char *dst) return latency; } +static int surf_parse_models_setup_already_called=0; +/* Call the last initialization functions, that must be called after the + * tag, if any, and before the first of cluster|peer|AS|trace|trace_connect + */ +void surf_parse_models_setup() +{ + if (surf_parse_models_setup_already_called) + return; + surf_parse_models_setup_already_called=1; + routing_parse_Erandom(); + surf_config_models_setup(); +} + + /** * \brief Recursive function for finalize * @@ -874,6 +888,8 @@ static void finalize(void) xbt_dynar_free(&(global_routing->last_route)); /* delete global routing structure */ xbt_free(global_routing); + /* make sure that we will reinit the models while loading the platf once reinited -- HACK but there is no proper surf_routing_init() */ + surf_parse_models_setup_already_called = 0; } static xbt_dynar_t recursive_get_onelink_routes(routing_component_t rc) @@ -995,19 +1011,6 @@ void surf_parse_add_callback_config(void) surfxml_add_callback(STag_surfxml_random_cb_list, &routing_parse_Srandom); } -static int surf_parse_models_setup_already_called=0; -/* Call the last initialization functions, that must be called after the - * tag, if any, and before the first of cluster|peer|AS|trace|trace_connect - */ -void surf_parse_models_setup() -{ - if (surf_parse_models_setup_already_called) - return; - surf_parse_models_setup_already_called=1; - routing_parse_Erandom(); - surf_config_models_setup(); -} - /* ************************************************** */ /* ********** PATERN FOR NEW ROUTING **************** */ @@ -1870,7 +1873,6 @@ static void clean_routing_after_parse(void) { xbt_dict_free(&random_value); xbt_dict_free(&patterns); - surf_parse_models_setup_already_called = 0; /* make sure that this function will be called again when reloading a platf */ } static void routing_parse_Speer(void) -- 2.20.1