From b380659d4cf88b049bfac7e75780a0cff8ae7b5d Mon Sep 17 00:00:00 2001 From: Lucas Schnorr Date: Tue, 6 Sep 2011 13:03:14 +0200 Subject: [PATCH] new function get_route_or_null that catches any exception before returning details: - this function is used by the tracing mechanism to extract the network topology of the platform being simulated --- src/surf/surf_private.h | 1 + src/surf/surf_routing.c | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/surf/surf_private.h b/src/surf/surf_private.h index 2ff37935db..d1bc0fc6f0 100644 --- a/src/surf/surf_private.h +++ b/src/surf/surf_private.h @@ -183,6 +183,7 @@ struct s_routing_global { void *loopback; size_t size_of_link; xbt_dynar_t(*get_route) (const char *src, const char *dst); + xbt_dynar_t(*get_route_or_null) (const char *src, const char *dst); xbt_dynar_t(*get_route_no_cleanup) (const char *src, const char *dst); xbt_dynar_t(*get_onelink_routes) (void); double (*get_latency) (const char *src, const char *dst); diff --git a/src/surf/surf_routing.c b/src/surf/surf_routing.c index 184ce558eb..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; -- 2.20.1