Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix a few memory leaks.
[simgrid.git] / src / surf / surf_routing.c
index 9d5f059..8e25069 100644 (file)
@@ -710,6 +710,14 @@ void routing_model_create( void *loopback)
 /* ************************************************************************** */
 /* ************************* GENERIC PARSE FUNCTIONS ************************ */
 
+void routing_cluster_add_backbone(void* bb) {
+  xbt_assert(current_routing->model_desc == &routing_models[SURF_MODEL_CLUSTER],
+        "You have to be in model Cluster to use tag backbone!");
+  xbt_assert(!((as_cluster_t)current_routing)->backbone,"The backbone link is already defined!");
+  ((as_cluster_t)current_routing)->backbone = bb;
+  XBT_DEBUG("Add a backbone to AS '%s'",current_routing->name);
+}
+
 static void routing_parse_cabinet(sg_platf_cabinet_cbarg_t cabinet)
 {
   int start, end, i;
@@ -912,10 +920,11 @@ static void routing_parse_cluster(sg_platf_cluster_cbarg_t cluster)
         bprintf("%s%s_router%s", cluster->prefix, cluster->id,
                 cluster->suffix);
   sg_platf_new_router(&router);
+  ((as_cluster_t)current_routing)->router = xbt_lib_get_or_null(as_router_lib, router.id, ROUTING_ASR_LEVEL);
   free(newid);
 
   //Make the backbone
-  if ((cluster->bb_bw != 0) && (cluster->bb_lat != 0)) {
+  if ((cluster->bb_bw != 0) || (cluster->bb_lat != 0)) {
     char *link_backbone = bprintf("%s_backbone", cluster->id);
     XBT_DEBUG("<link\tid=\"%s\" bw=\"%f\" lat=\"%f\"/>", link_backbone,
               cluster->bb_bw, cluster->bb_lat);
@@ -929,8 +938,7 @@ static void routing_parse_cluster(sg_platf_cluster_cbarg_t cluster)
 
     sg_platf_new_link(&link);
 
-    ((as_cluster_t)current_routing)->backbone = xbt_lib_get_or_null(link_lib, link_backbone, SURF_LINK_LEVEL);
-    XBT_DEBUG("Add a backbone to AS '%s'",current_routing->name);
+    routing_cluster_add_backbone(xbt_lib_get_or_null(link_lib, link_backbone, SURF_LINK_LEVEL));
 
     free(link_backbone);
   }