Module: kamailio
Branch: master
Commit: abd02c40d7f3379f8b72d73e89ab630167b5e514
URL: 
https://github.com/kamailio/kamailio/commit/abd02c40d7f3379f8b72d73e89ab630167b5e514

Author: Savolainen Dmitri <[email protected]>
Committer: Savolainen Dmitri <[email protected]>
Date: 2015-06-23T15:00:20+03:00

dispatcher: use last active destination for relative weight distribution array 
finishing  instead of last in destination set

---

Modified: modules/dispatcher/dispatch.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/abd02c40d7f3379f8b72d73e89ab630167b5e514.diff
Patch: 
https://github.com/kamailio/kamailio/commit/abd02c40d7f3379f8b72d73e89ab630167b5e514.patch

---

diff --git a/modules/dispatcher/dispatch.c b/modules/dispatcher/dispatch.c
index 9078c4e..a12ede8 100644
--- a/modules/dispatcher/dispatch.c
+++ b/modules/dispatcher/dispatch.c
@@ -471,10 +471,11 @@ int dp_init_relative_weights(ds_set_t *dset)
                        t++;
                }
        }
-       /* if the array was not completely filled (i.e., the sum of weights is
+       /* if the array was not completely filled (i.e., the sum of rweights is
         * less than 100 due to truncated), then use last address to fill the 
rest */
-       for(; t<100; t++)
-               dset->rwlist[t] = (unsigned int)(dset->nr-1);
+       unsigned int last_insert = t>0? dset->rwlist[t-1] : (unsigned 
int)(dset->nr-1); 
+       for(j=t; j<100; j++)
+               dset->rwlist[j] = last_insert;
 
        /* shuffle the content of the array in order to mix the selection
         * of the addresses (e.g., if first address has weight=20, avoid


_______________________________________________
sr-dev mailing list
[email protected]
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to