Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
/me hates globals
authorMartin Quinson <martin.quinson@loria.fr>
Tue, 8 Nov 2011 15:04:22 +0000 (16:04 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Tue, 8 Nov 2011 21:43:40 +0000 (22:43 +0100)
src/surf/surf.c
src/surf/surf_private.h
src/surf/surf_routing.c
src/surf/surf_routing_cluster.c
src/surf/surf_routing_private.h

index 78f3834..9a57398 100644 (file)
@@ -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_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();
 
   tmgr_finalize();
   surf_parse_lex_destroy();
index 0846990..1c7b932 100644 (file)
@@ -30,7 +30,6 @@ extern double sg_gtnets_jitter;
 extern int sg_gtnets_jitter_seed;
 #endif
 
 extern int sg_gtnets_jitter_seed;
 #endif
 
-extern xbt_dict_t cluster_host_link;
 
 extern const char *surf_action_state_names[6];
 
 
 extern const char *surf_action_state_names[6];
 
index cb103a7..76ac3e8 100644 (file)
@@ -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;
 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");
 
 
 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,
 {"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}
 };
 
 {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)
 {
 
 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;
 
   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;
                }
                        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);
 
                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;
                }
                        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);
 
                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;
          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);
   }
 
          free(link_backbone);
   }
 
index d0f6cd1..5a8d22b 100644 (file)
@@ -7,10 +7,6 @@
 
 /* Global vars */
 extern routing_global_t global_routing;
 
 /* 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");
 
 
 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.
  */
 
  * 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;
 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;
 }
 
   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);
+}
index 5e98558..15a2090 100644 (file)
@@ -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 */
 /* ************************************************** */
 /* **************  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   **************** */
 
 /* ************************************************** */
 /* **************  Vivaldi ROUTING   **************** */