From 82fe4076164f5dce0e55205a7d0fef71d0fc07bb Mon Sep 17 00:00:00 2001 From: Yacine Belkadi Date: Tue, 29 Mar 2011 17:39:30 +0200 Subject: cleo/app/igmp_snoopd: refactor: add update_computed_metrics() --- cleopatre/application/igmp_snoopd/src/igmp_v3.c | 30 ++++++++++++++++--------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/cleopatre/application/igmp_snoopd/src/igmp_v3.c b/cleopatre/application/igmp_snoopd/src/igmp_v3.c index dd83147ddf..983677466b 100644 --- a/cleopatre/application/igmp_snoopd/src/igmp_v3.c +++ b/cleopatre/application/igmp_snoopd/src/igmp_v3.c @@ -117,6 +117,24 @@ compute_group_membership_interval (const struct v3_metrics *metrics) + metrics->query_response_interval); } +/** + * Update the computed metrics. + * + * Some of the metrics are computed from the values of other metrics. + * This function updates these computed metrics. + * + * \param metrics The metrics. + */ +void +update_computed_metrics (struct v3_metrics *metrics) +{ + metrics->other_querier_present_interval = + compute_other_querier_present_interval (metrics); + + metrics->group_membership_interval = + compute_group_membership_interval (metrics); +} + /** * Update some timers and timestamps in the group and member. * They are used to keep track of (in)activity. @@ -205,11 +223,7 @@ init_v3 (struct v3_metrics *metrics) metrics->robustness_variable = DEFAULT_ROBUSTNESS_VARIABLE; metrics->query_interval = DEFAULT_QUERY_INTERVAL; metrics->query_response_interval = DEFAULT_QUERY_RESPONSE_INTERVAL; - - metrics->other_querier_present_interval = - compute_other_querier_present_interval (metrics); - metrics->group_membership_interval = - compute_group_membership_interval (metrics); + update_computed_metrics (metrics); } void @@ -282,11 +296,7 @@ process_v3_query (struct context *ctx, } /* the else case is already handled by a previous if in this function */ - ctx->metrics.other_querier_present_interval = - compute_other_querier_present_interval (&ctx->metrics); - - ctx->metrics.group_membership_interval = - compute_group_membership_interval (&ctx->metrics); + update_computed_metrics (&ctx->metrics); } /** -- cgit v1.2.3