Module: sip-router
Branch: master
Commit: 0f5e21c668e46492fb9f9ec69e5b5aafe41bd272
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=0f5e21c…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Fri Dec 3 10:45:00 2010 +0100
dispatcher(k): fixed use of use_default parameter
- when there was a single destination in destination set and it was in
inactive state, then having parameter use_default=1 caused a divion by
0 while atteptimpting to look for active destaintaion
- reported by Eric Hiller
---
modules_k/dispatcher/dispatch.c | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/modules_k/dispatcher/dispatch.c b/modules_k/dispatcher/dispatch.c
index bcd7f7c..e42f5d8 100644
--- a/modules_k/dispatcher/dispatch.c
+++ b/modules_k/dispatcher/dispatch.c
@@ -1717,15 +1717,20 @@ int ds_select_dst(struct sip_msg *msg, int set, int alg, int
mode)
while ((idx->dlist[i].flags & DS_INACTIVE_DST)
|| (idx->dlist[i].flags & DS_PROBING_DST))
{
- if(ds_use_default!=0)
+ if(ds_use_default!=0 && idx->nr!=1)
i = (i+1)%(idx->nr-1);
else
i = (i+1)%idx->nr;
if(i==hash)
{
+ /* back to start -- looks like no active dst */
if(ds_use_default!=0)
{
i = idx->nr-1;
+ if((idx->dlist[i].flags & DS_INACTIVE_DST)
+ || (idx->dlist[i].flags & DS_PROBING_DST))
+ return -1;
+ break;
} else {
return -1;
}
@@ -1751,6 +1756,7 @@ int ds_select_dst(struct sip_msg *msg, int set, int alg, int mode)
if(dst_avp_name.n!=0)
{
+ /* add default dst to last position in AVP list */
if(ds_use_default!=0 && hash!=idx->nr-1)
{
avp_val.s = idx->dlist[idx->nr-1].uri;