From daeddd3f498ff67738e1c16a1b1ee1506dd64c1b Mon Sep 17 00:00:00 2001 From: Marc Olivier Chouinard Date: Sat, 27 Feb 2010 16:24:09 +0000 Subject: [PATCH] mod_distributor: Fix segfault when no node are added, and add the support to have a single node with total weight of 1 only git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16842 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/mod/applications/mod_distributor/mod_distributor.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mod/applications/mod_distributor/mod_distributor.c b/src/mod/applications/mod_distributor/mod_distributor.c index 24ab9c682e..b0ff2d583a 100644 --- a/src/mod/applications/mod_distributor/mod_distributor.c +++ b/src/mod/applications/mod_distributor/mod_distributor.c @@ -157,7 +157,7 @@ static int load_config(int reloading) continue; } - if (tmp >= lp->target_weight) { + if (tmp >= lp->target_weight && (lp->target_weight == 1 && tmp != 1)) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Weight %d value incorrect, must be less than %d\n", tmp, lp->target_weight); continue; } @@ -196,7 +196,7 @@ static int load_config(int reloading) if (accum < lp->target_weight) { struct dist_node *np1; int remain = lp->target_weight - accum; - int ea = remain / lp->node_count ? lp->node_count : 1; + int ea = remain / (lp->node_count ? lp->node_count : 1); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Total weight does not add up to total weight %d\n", lp->target_weight);