From: Martin Quinson Date: Tue, 8 Nov 2011 15:04:22 +0000 (+0100) Subject: /me hates globals X-Git-Tag: exp_20120216~418 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/f40e862eaadb8abf4d87d6c1ae2dc085ed5fd81b?hp=b9c9ef88e5a31a819e1f197b563974705e6d6805 /me hates globals --- diff --git a/src/surf/surf.c b/src/surf/surf.c index 78f383487c..9a57398ac6 100644 --- a/src/surf/surf.c +++ b/src/surf/surf.c @@ -393,7 +393,7 @@ void surf_exit(void) xbt_lib_free(&host_lib); xbt_lib_free(&link_lib); xbt_lib_free(&as_router_lib); - xbt_dict_free(&cluster_host_link); + tmgr_finalize(); surf_parse_lex_destroy(); diff --git a/src/surf/surf_private.h b/src/surf/surf_private.h index 0846990785..1c7b932174 100644 --- a/src/surf/surf_private.h +++ b/src/surf/surf_private.h @@ -30,7 +30,6 @@ extern double sg_gtnets_jitter; extern int sg_gtnets_jitter_seed; #endif -extern xbt_dict_t cluster_host_link; extern const char *surf_action_state_names[6]; diff --git a/src/surf/surf_routing.c b/src/surf/surf_routing.c index cb103a7a2b..76ac3e8490 100644 --- a/src/surf/surf_routing.c +++ b/src/surf/surf_routing.c @@ -47,7 +47,6 @@ static const char *dst = NULL; /* temporary store the destination name of static char *gw_src = NULL; /* temporary store the gateway source name of a route */ static char *gw_dst = NULL; /* temporary store the gateway destination name of a route */ static double_f_cpvoid_t get_link_latency = NULL; -xbt_dict_t cluster_host_link = NULL; /* for tag cluster */ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route, surf, "Routing part of surf"); @@ -94,7 +93,7 @@ struct s_model_type routing_models[] = { {"Full", {"Vivaldi", "Vivaldi routing", model_vivaldi_create, model_none_load, model_none_unload, model_none_end}, {"Cluster", "Cluster routing", model_cluster_create, - model_none_load, model_none_unload, model_none_end}, + model_none_load, model_cluster_unload, model_none_end}, {NULL, NULL, NULL, NULL, NULL, NULL} }; @@ -1374,9 +1373,6 @@ void generic_src_dst_check(routing_component_t rc, const char *src, void routing_parse_Scluster(void) { - if(!cluster_host_link) - cluster_host_link = xbt_dict_new(); - static int AX_ptr = 0; char *host_id, *groups, *link_id = NULL; @@ -1499,7 +1495,7 @@ void routing_parse_Scluster(void) info->link_up = xbt_lib_get_or_null(link_lib, link_id, SURF_LINK_LEVEL); info->link_down = info->link_up; } - xbt_dict_set(cluster_host_link,host_id,info,xbt_free); + surf_routing_cluster_add_link(host_id,info); xbt_free(link_id); xbt_free(host_id); @@ -1585,7 +1581,8 @@ void routing_parse_Scluster(void) info->link_up = xbt_lib_get_or_null(link_lib, link_id, SURF_LINK_LEVEL); info->link_down = info->link_up; } - xbt_dict_set(cluster_host_link,host_id,info,xbt_free); + surf_routing_cluster_add_link(host_id,info); + xbt_free(link_id); xbt_free(host_id); @@ -1642,7 +1639,8 @@ void routing_parse_Scluster(void) surf_parsing_link_up_down_t info = xbt_new0(s_surf_parsing_link_up_down_t, 1); info->link_up = xbt_lib_get_or_null(link_lib, link_backbone, SURF_LINK_LEVEL); info->link_down = info->link_up; - xbt_dict_set(cluster_host_link,struct_cluster->id,info,xbt_free); + surf_routing_cluster_add_link(struct_cluster->id, info); + free(link_backbone); } diff --git a/src/surf/surf_routing_cluster.c b/src/surf/surf_routing_cluster.c index d0f6cd1161..5a8d22b3a3 100644 --- a/src/surf/surf_routing_cluster.c +++ b/src/surf/surf_routing_cluster.c @@ -7,10 +7,6 @@ /* Global vars */ extern routing_global_t global_routing; -extern routing_component_t current_routing; -extern model_type_t current_routing_model; -extern xbt_dynar_t link_list; -extern xbt_dict_t cluster_host_link; XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_cluster, surf, "Routing part of surf"); @@ -18,6 +14,8 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_cluster, surf, "Routing part of surf" * Note that a router is created, easing the interconnexion with the rest of the world. */ +static xbt_dict_t cluster_host_link = NULL; /* for tag cluster */ + typedef struct { s_routing_component_t generic_routing; xbt_dict_t dict_processing_units; @@ -57,3 +55,13 @@ void *model_cluster_create(void) return new_component; } +void model_cluster_unload(void) { +// xbt_dict_free(&cluster_host_link); //FIXME: do it once the module management is clean in routing +} + +void surf_routing_cluster_add_link(const char* host_id,surf_parsing_link_up_down_t info) { + if(!cluster_host_link) + cluster_host_link = xbt_dict_new(); + + xbt_dict_set(cluster_host_link,host_id,info,xbt_free); +} diff --git a/src/surf/surf_routing_private.h b/src/surf/surf_routing_private.h index 5e98558968..15a2090272 100644 --- a/src/surf/surf_routing_private.h +++ b/src/surf/surf_routing_private.h @@ -78,6 +78,9 @@ void *model_rulebased_create(void); /* create structures for rulebased rout /* ************************************************** */ /* ************** Cluster ROUTING **************** */ void *model_cluster_create(void); /* create structures for cluster routing model */ +void model_cluster_unload(void); /* Finalize the routing model */ + +void surf_routing_cluster_add_link(const char* host_id,surf_parsing_link_up_down_t info); /* ************************************************** */ /* ************** Vivaldi ROUTING **************** */