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
This commit is contained in:
Marc Olivier Chouinard 2010-02-27 16:24:09 +00:00
parent a705693354
commit daeddd3f49
1 changed files with 2 additions and 2 deletions

View File

@ -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);