Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
AS->get_route is no longer in charge of creating the route it fills
authorMartin Quinson <martin.quinson@loria.fr>
Tue, 15 Nov 2011 00:35:56 +0000 (01:35 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Tue, 15 Nov 2011 00:35:56 +0000 (01:35 +0100)
The whole idea is to reduce the dynar creation, copy, destroy madness
in the router. This step is only the first one on that way.

It may well happen that this change leads to massive memleaks. I'll
check after this later.

12 files changed:
src/instr/instr_routing.c
src/surf/surf_private.h
src/surf/surf_routing.c
src/surf/surf_routing_cluster.c
src/surf/surf_routing_dijkstra.c
src/surf/surf_routing_floyd.c
src/surf/surf_routing_full.c
src/surf/surf_routing_generic.c
src/surf/surf_routing_none.c
src/surf/surf_routing_private.h
src/surf/surf_routing_rulebased.c
src/surf/surf_routing_vivaldi.c

index d0d7750..e75817c 100644 (file)
@@ -137,7 +137,9 @@ static void recursiveGraphExtraction (AS_t rc, container_t container, xbt_dict_t
                 child2->kind == INSTR_AS &&
                 strcmp(child1_name, child2_name) != 0){
 
-        route_t route = rc->get_route (rc, child1_name, child2_name);
+        route_t route = xbt_new0(s_route_t,1);
+        route->link_list = xbt_dynar_new(global_routing->size_of_link,NULL);
+        rc->get_route (rc, child1_name, child2_name, route);
         unsigned int cpt;
         void *link;
         container_t previous = getContainerByName(route->src_gateway);
@@ -149,6 +151,7 @@ static void recursiveGraphExtraction (AS_t rc, container_t container, xbt_dict_t
         }
         container_t last = getContainerByName(route->dst_gateway);
         linkContainers (container, previous, last, filter);
+        generic_free_route(route);
       }
     }
   }
@@ -418,6 +421,7 @@ static void recursiveXBTGraphExtraction (xbt_graph_t graph, xbt_dict_t nodes, xb
           (child2->kind == INSTR_HOST  || child2->kind == INSTR_ROUTER) &&
           strcmp (child1_name, child2_name) != 0){
 
+        // FIXME factorize route creation once possible
         xbt_dynar_t route = routing_get_route (child1_name, child2_name);
         if (TRACE_onelink_only()){
           if (xbt_dynar_length (route) > 1) continue;
@@ -439,7 +443,9 @@ static void recursiveXBTGraphExtraction (xbt_graph_t graph, xbt_dict_t nodes, xb
                 child2->kind == INSTR_AS &&
                 strcmp(child1_name, child2_name) != 0){
 
-        route_t route = rc->get_route (rc, child1_name, child2_name);
+        route_t route = xbt_new0(s_route_t,1);
+        route->link_list = xbt_dynar_new(global_routing->size_of_link,NULL);
+        rc->get_route (rc, child1_name, child2_name,route);
         unsigned int cpt;
         void *link;
         xbt_node_t current, previous = new_xbt_graph_node(graph, route->src_gateway, nodes);
@@ -451,6 +457,7 @@ static void recursiveXBTGraphExtraction (xbt_graph_t graph, xbt_dict_t nodes, xb
         }
         current = new_xbt_graph_node(graph, route->dst_gateway, nodes);
         new_xbt_graph_edge (graph, previous, current, edges);
+        generic_free_route(route);
       }
     }
   }
index d911f0a..323885f 100644 (file)
@@ -132,7 +132,7 @@ typedef struct s_as {
   struct s_as *routing_father;
   xbt_dict_t routing_sons;
 
-  route_t(*get_route) (AS_t as, const char *src, const char *dst);
+  void (*get_route) (AS_t as, const char *src, const char *dst, route_t into);
   double(*get_latency) (AS_t as,
                         const char *src, const char *dst,
                         route_t e_route);
@@ -173,6 +173,8 @@ struct s_routing_global {
 XBT_PUBLIC(void) routing_model_create(size_t size_of_link, void *loopback);
 XBT_PUBLIC(void) routing_exit(void);
 XBT_PUBLIC(void) routing_register_callbacks(void);
+XBT_PUBLIC(void) generic_free_route(route_t route); // FIXME rename to routing_route_free
+
 
 XBT_PUBLIC(xbt_dynar_t) routing_get_route(const char *src, const char *dst);
 XBT_PUBLIC(void) routing_get_route_and_latency(const char *src, const char *dst, //FIXME too much functions avail?
index b2dc173..42790c6 100644 (file)
@@ -500,9 +500,10 @@ static void _get_route_and_latency(const char *src, const char *dst,
   /* If src and dst are in the same AS, life is good */
   if (src_father == dst_father) {       /* SURF_ROUTING_BASE */
 
-    route_t e_route = NULL;
+    route_t e_route = xbt_new0(s_route_t, 1);
+    e_route->link_list = xbt_dynar_new(global_routing->size_of_link, NULL);
     if (route) {
-      e_route = common_father->get_route(common_father, src, dst);
+      common_father->get_route(common_father, src, dst, e_route);
       xbt_assert(e_route, "no route between \"%s\" and \"%s\"", src, dst);
       *route = e_route->link_list;
     }
@@ -544,10 +545,9 @@ static void _get_route_and_latency(const char *src, const char *dst,
 
   /* Not in the same AS, no bypass. We'll have to find our path between the ASes recursively*/
 
-  route_t e_route_cnt = e_route_bypass
-      ? e_route_bypass : common_father->get_route(common_father,
-          src_father->name,
-          dst_father->name);
+  route_t e_route_cnt = xbt_new0(s_route_t, 1);
+  e_route_cnt->link_list = xbt_dynar_new(global_routing->size_of_link, NULL);
+  common_father->get_route(common_father, src_father->name, dst_father->name, e_route_cnt);
 
   xbt_assert(e_route_cnt, "no route between \"%s\" and \"%s\"",
       src_father->name, dst_father->name);
index 444ddb3..3af7568 100644 (file)
@@ -23,28 +23,20 @@ typedef struct {
 static xbt_dict_t cluster_host_link = NULL;
 
 /* Business methods */
-static route_t cluster_get_route(AS_t as,
-                                          const char *src,
-                                          const char *dst) {
-
-         xbt_dynar_t links_list = xbt_dynar_new(global_routing->size_of_link, NULL);
+static void cluster_get_route(AS_t as,
+                              const char *src, const char *dst,
+                              route_t route) {
 
          surf_parsing_link_up_down_t info;
 
          info = xbt_dict_get_or_null(cluster_host_link,src);
-         if(info) xbt_dynar_push_as(links_list,void*,info->link_up); //link_up
+         if(info) xbt_dynar_push_as(route->link_list,void*,info->link_up); //link_up
 
          if ( ((as_cluster_t)as)->backbone )
-           xbt_dynar_push_as(links_list,void*, ((as_cluster_t)as)->backbone) ;
+           xbt_dynar_push_as(route->link_list,void*, ((as_cluster_t)as)->backbone) ;
 
          info = xbt_dict_get_or_null(cluster_host_link,dst);
-         if(info) xbt_dynar_push_as(links_list,void*,info->link_down); //link_down
-
-         route_t new_e_route = NULL;
-         new_e_route = xbt_new0(s_route_t, 1);
-         new_e_route->link_list = links_list;
-
-         return new_e_route;
+         if(info) xbt_dynar_push_as(route->link_list,void*,info->link_down); //link_down
 }
 
 static void model_cluster_finalize(AS_t as) {
index 3de1ad1..02aef55 100644 (file)
@@ -165,9 +165,8 @@ static void add_loopback_dijkstra(as_dijkstra_t as) {
   }
 }
 
-static route_t dijkstra_get_route(AS_t as_generic,
-        const char *src,
-        const char *dst);
+static void dijkstra_get_route(AS_t as_generic,
+        const char *src, const char *dst, route_t route);
 
 static xbt_dynar_t dijkstra_get_onelink_routes(AS_t as)
 {
@@ -179,32 +178,33 @@ static xbt_dynar_t dijkstra_get_onelink_routes(AS_t as)
          char *k1, *d1, *k2, *d2;
          xbt_dict_foreach(as->to_index, c1, k1, d1) {
            xbt_dict_foreach(as->to_index, c2, k2, d2) {
-             route_t route = dijkstra_get_route(as, k1, k2);
-             if (route) {
-               if (xbt_dynar_length(route->link_list) == 1) {
-                 void *link =
-                     *(void **) xbt_dynar_get_ptr(route->link_list, 0);
-                 onelink_t onelink = xbt_new0(s_onelink_t, 1);
-                 onelink->link_ptr = link;
-                 if (as->hierarchy == SURF_ROUTING_BASE) {
-                   onelink->src = xbt_strdup(k1);
-                   onelink->dst = xbt_strdup(k2);
-                 } else if (as->hierarchy ==
-                            SURF_ROUTING_RECURSIVE) {
-                   onelink->src = xbt_strdup(route->src_gateway);
-                   onelink->dst = xbt_strdup(route->dst_gateway);
-                 }
-                 xbt_dynar_push(ret, &onelink);
+             route_t route = xbt_new0(s_route_t,1);
+             route->link_list = xbt_dynar_new(global_routing->size_of_link,NULL);
+             dijkstra_get_route(as, k1, k2,route);
+
+             if (xbt_dynar_length(route->link_list) == 1) {
+               void *link =
+                   *(void **) xbt_dynar_get_ptr(route->link_list, 0);
+               onelink_t onelink = xbt_new0(s_onelink_t, 1);
+               onelink->link_ptr = link;
+               if (as->hierarchy == SURF_ROUTING_BASE) {
+                 onelink->src = xbt_strdup(k1);
+                 onelink->dst = xbt_strdup(k2);
+               } else if (as->hierarchy ==
+                   SURF_ROUTING_RECURSIVE) {
+                 onelink->src = xbt_strdup(route->src_gateway);
+                 onelink->dst = xbt_strdup(route->dst_gateway);
                }
+               xbt_dynar_push(ret, &onelink);
              }
            }
          }
          return ret;
 }
 
-static route_t dijkstra_get_route(AS_t asg,
-                                           const char *src,
-                                           const char *dst)
+static void dijkstra_get_route(AS_t asg,
+                               const char *src, const char *dst,
+                               route_t route)
 {
   xbt_assert(asg && src
               && dst,
@@ -222,12 +222,6 @@ static route_t dijkstra_get_route(AS_t asg,
               "Ask for route \"from\"(%s)  or \"to\"(%s) no found in the local table",
               src, dst);
 
-  /* create a result route */
-  route_t new_e_route = xbt_new0(s_route_t, 1);
-  new_e_route->link_list = xbt_dynar_new(global_routing->size_of_link, NULL);
-  new_e_route->src_gateway = NULL;
-  new_e_route->dst_gateway = NULL;
-
   int *pred_arr = NULL;
   int src_node_id = 0;
   int dst_node_id = 0;
@@ -269,10 +263,9 @@ static route_t dijkstra_get_route(AS_t asg,
 
     links = e_route->link_list;
     xbt_dynar_foreach(links, cpt, link) {
-      xbt_dynar_unshift(new_e_route->link_list, &link);
+      xbt_dynar_unshift(route->link_list, &link);
     }
 
-    return new_e_route;
   }
 
   if (as->cached) {
@@ -374,21 +367,21 @@ static route_t dijkstra_get_route(AS_t asg,
       links = e_route_as_to_as;
       int pos = 0;
       xbt_dynar_foreach(links, cpt, link) {
-        xbt_dynar_insert_at(new_e_route->link_list, pos, &link);
+        xbt_dynar_insert_at(route->link_list, pos, &link);
         pos++;
       }
     }
 
     links = e_route->link_list;
     xbt_dynar_foreach(links, cpt, link) {
-      xbt_dynar_unshift(new_e_route->link_list, &link);
+      xbt_dynar_unshift(route->link_list, &link);
     }
     size++;
   }
 
   if (asg->hierarchy == SURF_ROUTING_RECURSIVE) {
-    new_e_route->src_gateway = xbt_strdup(gw_src);
-    new_e_route->dst_gateway = xbt_strdup(first_gw);
+    route->src_gateway = xbt_strdup(gw_src);
+    route->dst_gateway = xbt_strdup(first_gw);
   }
 
   if (as->cached && elm == NULL) {
@@ -402,8 +395,6 @@ static route_t dijkstra_get_route(AS_t asg,
 
   if (!as->cached)
     xbt_free(pred_arr);
-
-  return new_e_route;
 }
 
 static void dijkstra_finalize(AS_t asg)
index f75470d..7e4f4c2 100644 (file)
@@ -25,40 +25,41 @@ typedef struct {
   route_t *link_table;
 } s_as_floyd_t, *as_floyd_t;
 
-static route_t floyd_get_route(AS_t asg, const char *src, const char *dst);
+static void floyd_get_route(AS_t asg, const char *src, const char *dst, route_t res);
 
 /* Business methods */
 static xbt_dynar_t floyd_get_onelink_routes(AS_t asg)
 {
   xbt_dynar_t ret = xbt_dynar_new(sizeof(onelink_t), xbt_free);
 
+  route_t route =   xbt_new0(s_route_t, 1);
+  route->link_list = xbt_dynar_new(global_routing->size_of_link, NULL);
+
   xbt_dict_cursor_t c1 = NULL, c2 = NULL;
   char *k1, *d1, *k2, *d2;
   xbt_dict_foreach(asg->to_index, c1, k1, d1) {
     xbt_dict_foreach(asg->to_index, c2, k2, d2) {
-      route_t route = floyd_get_route(asg, k1, k2);
-      if (route) {
-        if (xbt_dynar_length(route->link_list) == 1) {
-          void *link =
-              *(void **) xbt_dynar_get_ptr(route->link_list, 0);
-          onelink_t onelink = xbt_new0(s_onelink_t, 1);
-          onelink->link_ptr = link;
-          if (asg->hierarchy == SURF_ROUTING_BASE) {
-            onelink->src = xbt_strdup(k1);
-            onelink->dst = xbt_strdup(k2);
-          } else if (asg->hierarchy == SURF_ROUTING_RECURSIVE) {
-            onelink->src = xbt_strdup(route->src_gateway);
-            onelink->dst = xbt_strdup(route->dst_gateway);
-          }
-          xbt_dynar_push(ret, &onelink);
+      xbt_dynar_reset(route->link_list);
+      floyd_get_route(asg, k1, k2, route);
+      if (xbt_dynar_length(route->link_list) == 1) {
+        void *link = *(void **) xbt_dynar_get_ptr(route->link_list, 0);
+        onelink_t onelink = xbt_new0(s_onelink_t, 1);
+        onelink->link_ptr = link;
+        if (asg->hierarchy == SURF_ROUTING_BASE) {
+          onelink->src = xbt_strdup(k1);
+          onelink->dst = xbt_strdup(k2);
+        } else if (asg->hierarchy == SURF_ROUTING_RECURSIVE) {
+          onelink->src = xbt_strdup(route->src_gateway);
+          onelink->dst = xbt_strdup(route->dst_gateway);
         }
+        xbt_dynar_push(ret, &onelink);
       }
     }
   }
   return ret;
 }
 
-static route_t floyd_get_route(AS_t asg, const char *src, const char *dst)
+static void floyd_get_route(AS_t asg, const char *src, const char *dst, route_t res)
 {
   xbt_assert(asg && src
               && dst,
@@ -78,8 +79,6 @@ static route_t floyd_get_route(AS_t asg, const char *src, const char *dst)
               src, dst);
 
   /* create a result route */
-  route_t new_e_route = xbt_new0(s_route_t, 1);
-  new_e_route->link_list = xbt_dynar_new(global_routing->size_of_link, NULL);
 
   int first = 1;
   int pred = *dst_id;
@@ -116,14 +115,14 @@ static route_t floyd_get_route(AS_t asg, const char *src, const char *dst)
       links = e_route_as_to_as;
       int pos = 0;
       xbt_dynar_foreach(links, cpt, link) {
-        xbt_dynar_insert_at(new_e_route->link_list, pos, &link);
+        xbt_dynar_insert_at(res->link_list, pos, &link);
         pos++;
       }
     }
 
     links = e_route->link_list;
     xbt_dynar_foreach(links, cpt, link) {
-      xbt_dynar_unshift(new_e_route->link_list, &link);
+      xbt_dynar_unshift(res->link_list, &link);
     }
     first = 0;
 
@@ -132,11 +131,10 @@ static route_t floyd_get_route(AS_t asg, const char *src, const char *dst)
               *src_id, *dst_id, src, dst);
 
   if (asg->hierarchy == SURF_ROUTING_RECURSIVE) {
-    new_e_route->src_gateway = xbt_strdup(gw_src);
-    new_e_route->dst_gateway = xbt_strdup(first_gw);
+    res->src_gateway = xbt_strdup(gw_src);
+    res->dst_gateway = xbt_strdup(first_gw);
   }
 
-  return new_e_route;
 }
 
 static void floyd_finalize(AS_t rc)
index 464b4b2..9c7dc71 100644 (file)
@@ -61,8 +61,9 @@ static xbt_dynar_t full_get_onelink_routes(AS_t rc)
   return ret;
 }
 
-static route_t full_get_route(AS_t rc,
-                                       const char *src, const char *dst)
+static void full_get_route(AS_t rc,
+                           const char *src, const char *dst,
+                           route_t res)
 {
   xbt_assert(rc && src
               && dst,
@@ -81,23 +82,18 @@ static route_t full_get_route(AS_t rc,
               src, dst);
 
   route_t e_route = NULL;
-  route_t new_e_route = NULL;
   void *link;
   unsigned int cpt = 0;
 
   e_route = TO_ROUTE_FULL(*src_id, *dst_id);
 
   if (e_route) {
-    new_e_route = xbt_new0(s_route_t, 1);
-    new_e_route->src_gateway = xbt_strdup(e_route->src_gateway);
-    new_e_route->dst_gateway = xbt_strdup(e_route->dst_gateway);
-    new_e_route->link_list =
-        xbt_dynar_new(global_routing->size_of_link, NULL);
+    res->src_gateway = xbt_strdup(e_route->src_gateway);
+    res->dst_gateway = xbt_strdup(e_route->dst_gateway);
     xbt_dynar_foreach(e_route->link_list, cpt, link) {
-      xbt_dynar_push(new_e_route->link_list, &link);
+      xbt_dynar_push(res->link_list, &link);
     }
   }
-  return new_e_route;
 }
 
 static void full_finalize(AS_t rc)
index 6be5386..c42babf 100644 (file)
@@ -98,7 +98,11 @@ double generic_get_link_latency(AS_t rc,
   unsigned int i;
   double latency = 0.0;
 
-  route = route ? route : rc->get_route(rc, src, dst);
+  if (route == NULL) {
+    route = xbt_new0(s_route_t, 1);
+    route->link_list = xbt_dynar_new(global_routing->size_of_link, NULL);
+    rc->get_route(rc, src, dst, route);
+  }
 
   xbt_dynar_foreach(route->link_list, i, link) {
     latency += surf_network_model->extension.network.get_link_latency(link);
@@ -332,7 +336,7 @@ generic_new_extended_route(e_surf_routing_hierarchy_t hierarchy,
 void generic_free_route(route_t route)
 {
   if (route) {
-    xbt_dynar_free(&(route->link_list));
+    xbt_dynar_free(&route->link_list);
     xbt_free(route->src_gateway);
     xbt_free(route->dst_gateway);
     xbt_free(route);
index 66d6c43..fddd109 100644 (file)
@@ -12,10 +12,9 @@ static xbt_dynar_t none_get_onelink_routes(AS_t rc) {
   return NULL;
 }
 
-static route_t none_get_route(AS_t rc,
-                                       const char *src, const char *dst)
+static void none_get_route(AS_t rc, const char *src, const char *dst,
+                           route_t res)
 {
-  return NULL;
 }
 
 static route_t none_get_bypass_route(AS_t rc,
index a7fbeae..10dbeb6 100644 (file)
@@ -53,7 +53,6 @@ generic_new_extended_route(e_surf_routing_hierarchy_t hierarchy,
 route_t
 generic_new_route(e_surf_routing_hierarchy_t hierarchy,
                            void *data, int order);
-void generic_free_route(route_t route);
 AS_t
 generic_autonomous_system_exist(AS_t rc, char *element);
 AS_t
index 1c6ffaf..53e39b6 100644 (file)
@@ -205,9 +205,9 @@ static char *remplace(char *value, const char **src_list, int src_size,
   return memcpy(res, result, i_res);
 }
 
-static route_t rulebased_get_route(AS_t rc,
-                                            const char *src,
-                                            const char *dst);
+static void rulebased_get_route(AS_t rc,
+                                const char *src, const char *dst,
+                                route_t res);
 static xbt_dynar_t rulebased_get_onelink_routes(AS_t rc)
 {
   xbt_dynar_t ret = xbt_dynar_new (sizeof(onelink_t), xbt_free);
@@ -226,15 +226,17 @@ static xbt_dynar_t rulebased_get_onelink_routes(AS_t rc)
   xbt_dict_foreach(routing->dict_processing_units, c1, k1, d1) {
     if (routing_get_network_element_type(k1) == SURF_NETWORK_ELEMENT_ROUTER){
       router = k1;
+      break;
     }
   }
 
-  if (!router){
+  if (!router)
     xbt_die ("rulebased_get_onelink_routes works only if the AS is a cluster, sorry.");
-  }
 
   xbt_dict_foreach(routing->dict_processing_units, c1, k1, d1) {
-    route_t route = rulebased_get_route (rc, router, k1);
+    route_t route = xbt_new0(s_route_t,1);
+    route->link_list = xbt_dynar_new(global_routing->size_of_link,NULL);
+    rulebased_get_route (rc, router, k1, route);
 
     int number_of_links = xbt_dynar_length(route->link_list);
 
@@ -259,9 +261,9 @@ static xbt_dynar_t rulebased_get_onelink_routes(AS_t rc)
 }
 
 /* Business methods */
-static route_t rulebased_get_route(AS_t rc,
-                                            const char *src,
-                                            const char *dst)
+static void rulebased_get_route(AS_t rc,
+                                const char *src, const char *dst,
+                                route_t route)
 {
   xbt_assert(rc && src
               && dst,
@@ -269,8 +271,7 @@ static route_t rulebased_get_route(AS_t rc,
               rc->name);
 
   /* set utils vars */
-  AS_rulebased_t routing =
-      (AS_rulebased_t) rc;
+  AS_rulebased_t routing = (AS_rulebased_t) rc;
 
   int are_processing_units=0;
   xbt_dynar_t rule_list;
@@ -292,9 +293,6 @@ static route_t rulebased_get_route(AS_t rc,
   int src_length = (int) strlen(src);
   int dst_length = (int) strlen(dst);
 
-  xbt_dynar_t links_list =
-      xbt_dynar_new(global_routing->size_of_link, NULL);
-
   rule_route_t ruleroute;
   unsigned int cpt;
   int ovector_src[OVECCOUNT];
@@ -322,7 +320,7 @@ static route_t rulebased_get_route(AS_t rc,
           void *link =
                          xbt_lib_get_or_null(link_lib, new_link_name, SURF_LINK_LEVEL);
           if (link)
-            xbt_dynar_push(links_list, &link);
+            xbt_dynar_push(route->link_list, &link);
           else
             THROWF(mismatch_error, 0, "Link %s not found", new_link_name);
           xbt_free(new_link_name);
@@ -333,25 +331,21 @@ static route_t rulebased_get_route(AS_t rc,
       break;
   }
 
-  route_t new_e_route = NULL;
   if (rc_src >= 0 && rc_dst >= 0) {
-    new_e_route = xbt_new0(s_route_t, 1);
-    new_e_route->link_list = links_list;
+    /* matched src and dest, nothing more to do (?) */
   } else if (!strcmp(src, dst) && are_processing_units) {
-    new_e_route = xbt_new0(s_route_t, 1);
-    xbt_dynar_push(links_list, &(global_routing->loopback));
-    new_e_route->link_list = links_list;
+    xbt_dynar_push(route->link_list, &(global_routing->loopback));
   } else {
-    xbt_dynar_free(&link_list);
+    xbt_dynar_reset(route->link_list);
   }
 
-  if (!are_processing_units && new_e_route) {
+  if (!are_processing_units && !xbt_dynar_is_empty(route->link_list)) {
     rule_route_extended_t ruleroute_extended =
         (rule_route_extended_t) ruleroute;
-    new_e_route->src_gateway =
+    route->src_gateway =
         remplace(ruleroute_extended->re_src_gateway, list_src, rc_src,
                  list_dst, rc_dst);
-    new_e_route->dst_gateway =
+    route->dst_gateway =
         remplace(ruleroute_extended->re_dst_gateway, list_src, rc_src,
                  list_dst, rc_dst);
   }
@@ -360,8 +354,6 @@ static route_t rulebased_get_route(AS_t rc,
     pcre_free_substring_list(list_src);
   if (list_dst)
     pcre_free_substring_list(list_dst);
-
-  return new_e_route;
 }
 
 static route_t rulebased_get_bypass_route(AS_t rc, const char *src, const char *dst) {
index 9e7ddfe..22b9616 100644 (file)
@@ -8,18 +8,16 @@
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_vivaldi, surf, "Routing part of surf");
 
 /* Business methods */
-static route_t vivaldi_get_route(AS_t rc, const char *src, const char *dst)
+static void vivaldi_get_route(AS_t rc, const char *src, const char *dst,
+    route_t route)
 {
          xbt_assert(rc && src
                      && dst,
                      "Invalid params for \"get_route\" function at AS \"%s\"",
                      rc->name);
 
-         route_t new_e_route = xbt_new0(s_route_t, 1);
-         new_e_route->src_gateway = ROUTER_PEER(src);
-         new_e_route->dst_gateway = ROUTER_PEER(dst);
-         new_e_route->link_list =  xbt_dynar_new(0, NULL);
-         return new_e_route;
+         route->src_gateway = ROUTER_PEER(src);
+         route->dst_gateway = ROUTER_PEER(dst);
 }
 
 static XBT_INLINE double euclidean_dist_comp(int index, xbt_dynar_t src, xbt_dynar_t dst)
@@ -55,12 +53,9 @@ static double base_vivaldi_get_latency (const char *src, const char *dst)
 static double vivaldi_get_latency (AS_t rc,const char *src, const char *dst, route_t e_route)
 {
   if(routing_get_network_element_type(src) == SURF_NETWORK_ELEMENT_AS) {
-         int need_to_clean = e_route?0:1;
-         double latency;
-         e_route = e_route ? e_route : rc->get_route(rc, src, dst);
-         latency = base_vivaldi_get_latency(e_route->src_gateway,e_route->dst_gateway);
-         if(need_to_clean) generic_free_route(e_route);
-         return latency;
+    if (e_route)
+      return base_vivaldi_get_latency(e_route->src_gateway,e_route->dst_gateway);
+    return base_vivaldi_get_latency(ROUTER_PEER(src),ROUTER_PEER(dst));
   } else {
          return base_vivaldi_get_latency(src,dst);
   }