[sr-dev] git:master: uac_redirect: select the contacts with highest q when a limit is set

Daniel-Constantin Mierla miconda at gmail.com
Mon Mar 3 19:21:36 CET 2014


Module: sip-router
Branch: master
Commit: a9b3286a5ace0f66852054634b46c0647c8d1271
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=a9b3286a5ace0f66852054634b46c0647c8d1271

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Mon Mar  3 19:15:30 2014 +0100

uac_redirect: select the contacts with highest q when a limit is set

- reported by  Stefan Prelle, FS#349

---

 modules/uac_redirect/rd_funcs.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/modules/uac_redirect/rd_funcs.c b/modules/uac_redirect/rd_funcs.c
index f85d84d..6bed77f 100644
--- a/modules/uac_redirect/rd_funcs.c
+++ b/modules/uac_redirect/rd_funcs.c
@@ -165,7 +165,7 @@ static int sort_contacts(hdr_field_t *chdr, contact_t **ct_array,
 					ct_list->uri.len,ct_list->uri.s,q);
 			/*insert the contact into the sorted array */
 			for(i=0;i<n;i++) {
-				/* keep in mind that the contact list is reversts */
+				/* keep in mind that the contact list is reversed */
 				if (q_array[i]<=q)
 					continue;
 				break;
@@ -285,14 +285,18 @@ static int shmcontact2dset(struct sip_msg *req, struct sip_msg *sh_rpl,
 		goto restore;
 	}
 
-	/* to many branches ? */
+	i=0;
+
+	/* more branches than requested in the parameter
+	 * - add only the last ones from sorted array,
+	 *   because the order is by increasing q */
 	if (max!=-1 && n>max)
-		n = max;
+		i = n - max;
 
 	added = 0;
 
 	/* add the sortet contacts as branches in dset and log this! */
-	for ( i=0 ; i<n ; i++ ) {
+	for (  ; i<n ; i++ ) {
 		LM_DBG("adding contact <%.*s>\n", scontacts[i]->uri.len,
 				scontacts[i]->uri.s);
 		if(sruid_next(&_redirect_sruid)==0) {




More information about the sr-dev mailing list