]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
mod_distributor: Fix segfault when no node are added, and add the support to have...
authorMarc Olivier Chouinard <mochouinard@moctel.com>
Sat, 27 Feb 2010 16:24:09 +0000 (16:24 +0000)
committerMarc Olivier Chouinard <mochouinard@moctel.com>
Sat, 27 Feb 2010 16:24:09 +0000 (16:24 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16842 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/applications/mod_distributor/mod_distributor.c

index 24ab9c682e078301fdf9910a08b55db76bccf30e..b0ff2d583a6a292df375af50ca9a8c46ce09ba7d 100644 (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);