X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/3d712f99d8fadf7db4977d1c6fa634016f43a361..b380659d4cf88b049bfac7e75780a0cff8ae7b5d:/src/surf/surf_routing.c diff --git a/src/surf/surf_routing.c b/src/surf/surf_routing.c index 42d1eac6fa..8794bbcc30 100644 --- a/src/surf/surf_routing.c +++ b/src/surf/surf_routing.c @@ -809,6 +809,26 @@ static xbt_dynar_t get_route(const char *src, const char *dst) return route; } +/** + * \brief Generic method: find a route between hosts + * + * \param src the source host name + * \param dst the destination host name + * + * same as get_route, but return NULL if any exception is raised. + */ +static xbt_dynar_t get_route_or_null(const char *src, const char *dst) +{ + xbt_dynar_t route = NULL; + xbt_ex_t exception; + TRY { + get_route_latency(src, dst, &route, NULL, 1); + }CATCH(exception) { + return NULL; + } + return route; +} + /** * \brief Generic method: find a route between hosts * @@ -935,6 +955,7 @@ void routing_model_create(size_t size_of_links, void *loopback, double_f_cpvoid_ global_routing = xbt_new0(s_routing_global_t, 1); global_routing->root = NULL; global_routing->get_route = get_route; + global_routing->get_route_or_null = get_route_or_null; global_routing->get_latency = get_latency; global_routing->get_route_no_cleanup = get_route_no_cleanup; global_routing->get_onelink_routes = get_onelink_routes; @@ -1507,7 +1528,7 @@ void routing_parse_Scluster(void) char *cluster_availability_file = A_surfxml_cluster_availability_file; char *cluster_state_file = A_surfxml_cluster_state_file; char *host_id, *groups, *link_id = NULL; - char *router_id, *link_backbone; + char *router_id = xbt_strdup(A_surfxml_cluster_router_id); char *availability_file = xbt_strdup(cluster_availability_file); char *state_file = xbt_strdup(cluster_state_file); @@ -1686,9 +1707,8 @@ void routing_parse_Scluster(void) xbt_dynar_free(&radical_elements); XBT_DEBUG(" "); - router_id = - bprintf("%s%s_router%s", cluster_prefix, cluster_id, - cluster_suffix); + if(!strcmp(router_id,"")) + router_id = bprintf("%s%s_router%s", cluster_prefix, cluster_id, cluster_suffix); XBT_DEBUG("", router_id); SURFXML_BUFFER_SET(router_id, router_id); @@ -1697,7 +1717,7 @@ void routing_parse_Scluster(void) SURFXML_END_TAG(router); if(strcmp(cluster_bb_bw,"") && strcmp(cluster_bb_lat,"")){ - link_backbone = bprintf("%s_backbone", cluster_id); + char *link_backbone = bprintf("%s_backbone", cluster_id); XBT_DEBUG("", link_backbone,cluster_bb_bw, cluster_bb_lat); A_surfxml_link_state = A_surfxml_link_state_ON; A_surfxml_link_sharing_policy = A_surfxml_link_sharing_policy_SHARED; @@ -1711,6 +1731,7 @@ void routing_parse_Scluster(void) SURFXML_BUFFER_SET(link_state_file, ""); SURFXML_START_TAG(link); SURFXML_END_TAG(link); + free(link_backbone); } XBT_DEBUG(" "); @@ -1920,8 +1941,6 @@ void routing_parse_Scluster(void) #endif free(router_id); - if(strcmp(cluster_bb_bw,"") && strcmp(cluster_bb_lat,"")) - free(link_backbone); xbt_dict_free(&patterns); free(availability_file); free(state_file);