Sfoglia il codice sorgente

dispatcher: ds_select_routes() - set r-uri/d-uri even when first group has no available dst

- GH #1728
Daniel-Constantin Mierla 6 anni fa
parent
commit
074d3c67a9

+ 1 - 0
src/modules/dispatcher/dispatch.c

@@ -2181,6 +2181,7 @@ int ds_manage_routes(sip_msg_t *msg, ds_select_state_t *rstate)
 					idx->dlist[hash].uri.len, idx->dlist[hash].uri.s);
 			return -1;
 		}
+		rstate->emode = 1;
 	}
 
 	LM_DBG("selected [%d-%d-%d/%d] <%.*s>\n", rstate->alg, rstate->setid,

+ 6 - 5
src/modules/dispatcher/dispatch.h

@@ -214,11 +214,12 @@ typedef struct _ds_set {
 } ds_set_t;
 
 typedef struct _ds_select_state {
-	int setid;
-	int alg;
-	int umode;
-	uint32_t limit;
-	int cnt;
+	int setid;  /* dispatcher set id (group id) */
+	int alg;    /* algorithm to select destionations */
+	int umode;  /* update mode - push to: r-uri, d-uri, xavp */
+	uint32_t limit; /* limit of destination addresses to be selected */
+	int cnt;    /* output: number of xavps set with destination addresses */
+	int emode;  /* output: update operation was executed or not */
 	sr_xavp_t *lxavp;
 } ds_select_state_t;
 

+ 4 - 5
src/modules/dispatcher/dispatcher.c

@@ -632,7 +632,6 @@ static int ki_ds_select_routes_limit(sip_msg_t *msg, str *srules, str *smode,
 	int i;
 	int vret;
 	int gret;
-	int vfirst;
 	sr_xval_t nxval;
 	ds_select_state_t vstate;
 
@@ -644,7 +643,6 @@ static int ki_ds_select_routes_limit(sip_msg_t *msg, str *srules, str *smode,
 	}
 	vret = -1;
 	gret = -1;
-	vfirst = 0;
 	i = 0;
 	while(i<srules->len) {
 		vstate.setid = 0;
@@ -677,9 +675,11 @@ static int ki_ds_select_routes_limit(sip_msg_t *msg, str *srules, str *smode,
 		}
 		LM_DBG("routing with setid=%d alg=%d cnt=%d limit=0x%x (%u)\n",
 			vstate.setid, vstate.alg, vstate.cnt, vstate.limit, vstate.limit);
-		
+
 		vstate.umode = DS_SETOP_XAVP;
-		if(vfirst==0) {
+		/* if no r-uri/d-uri was set already, keep using the update mode
+		 * specified by the param, then just add to xavps list */
+		if(vstate.emode==0) {
 			switch(smode->s[0]) {
 				case '0':
 				case 'd':
@@ -700,7 +700,6 @@ static int ki_ds_select_routes_limit(sip_msg_t *msg, str *srules, str *smode,
 							smode->len, smode->s);
 					return -1;
 			}
-			vfirst = 1;
 		}
 		vret = ds_manage_routes(msg, &vstate);
 		if(vret<0) {