Juha,

this change broke support for calling t_load_contacts from failure_route. When 
used from failure_route, the current ruri is added again as new branch. Can 
you elaborate on why the relevant code was removed?


Attached patch restores the functionality. Is there anything wrong with this 
fix or shall i commit it?

Alex.




On Friday 28 May 2010 14:43:32 Juha Heinanen wrote:
> Module: sip-router
> Branch: master
> Commit: e973bbe5e7310861f77b17ce0afaf1cca35fe48a
> URL:   
> http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=e973bb
> e5e7310861f77b17ce0afaf1cca35fe48a
> 
> Author: Juha Heinanen <j...@tutpro.com>
> Committer: Juha Heinanen <j...@tutpro.com>
> Date:   Fri May 28 15:38:41 2010 +0300
> 
> modules/tm: new implementation of load_contacts()/next_contacts()
> 
> - Simpler implementation of load_contacts()/next_contacts() functions
>   based on recent changes related to Request-URI handling.
> - Function next_contacts() does not anymore set any timers.  Check
>   contact_avp and call t_set_fr() before calling t_relay() instead.
> - Removed fr_timer_next module parameter, because it is not needed
>   anymore.
> 
> ---
> 
>  modules/tm/README            |  255 ++++++++++++++------------------------
>  modules/tm/doc/functions.xml |   51 +++-----
>  modules/tm/doc/params.xml    |   73 -----------
>  modules/tm/doc/tm.xml        |   15 +--
>  modules/tm/t_serial.c        |  279
> ++++++++++++------------------------------ modules/tm/tm.c              | 
>   1 -
>  6 files changed, 190 insertions(+), 484 deletions(-)
> 
> Diff:  
> http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commitdiff;h=e9
> 73bbe5e7310861f77b17ce0afaf1cca35fe48a
> 
> _______________________________________________
> sr-dev mailing list
> sr-dev@lists.sip-router.org
> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

-- 
Alex Hermann
commit 554a86e05cfde8ff19974a1aef7ca2a072e73cec
Author: Alex Hermann <a...@speakup.nl>
Date:   Mon Aug 1 16:09:38 2011 +0200

    modules/tm: fix t_load_contacts for failure_route
    
    Commit e973bbe5e7310861f77b17ce0afaf1cca35fe48a removed the logic for handling
    failure_route. The result was that when t_load_contacts is called from
    failure_route, the current request-uri is added as branch _again_.
    
    This commit restores the original functionality of ignoreing the request uri
    when called from failure_route.

diff --git a/modules/tm/t_serial.c b/modules/tm/t_serial.c
index 899cb5b..6cc4857 100644
--- a/modules/tm/t_serial.c
+++ b/modules/tm/t_serial.c
@@ -242,15 +242,21 @@ int t_load_contacts(struct sip_msg* msg, char* key, char* value)
     }
 
     ruri = (str *)0;
-
-    /* Take first q from Request-URI */
-    ruri = GET_RURI(msg);
-    if (!ruri) {
-	LM_ERR("no Request-URI found\n");
-	return -1;
+	if (! is_route_type(FAILURE_ROUTE | ONREPLY_ROUTE)) {
+		/* Take first q from Request-URI */
+		ruri = GET_RURI(msg);
+		if (!ruri) {
+			LM_ERR("no Request-URI found\n");
+			return -1;
+		}
+		first_q = get_ruri_q();
+		first_idx = 0;
+	} else {
+		/* Take first q from first branch */
+		uri.s = get_branch(0, &uri.len, &first_q, &dst_uri, &path, &flags,
+			               &sock);
+		first_idx = 1;
     }
-    first_q = get_ruri_q();
-    first_idx = 0;
 
     /* Check if all q values are equal */
     for(idx = first_idx; (tmp.s = get_branch(idx, &tmp.len, &q, 0, 0, 0, 0))
@@ -272,15 +278,24 @@ rest:
 		return -1;
     }
 
-    /* Insert Request-URI branch to first contact */
-    contacts->uri.s = ruri->s;
-    contacts->uri.len = ruri->len;
-    contacts->dst_uri = msg->dst_uri;
-    contacts->sock = msg->force_send_socket;
-    getbflagsval(0, &contacts->flags);
-    contacts->path = msg->path_vec;
-    contacts->q = first_q;
-    contacts->next = (struct contact *)0;
+	if (! is_route_type(FAILURE_ROUTE | ONREPLY_ROUTE)) {
+		/* Insert Request-URI branch to first contact */
+		contacts->uri.s = ruri->s;
+		contacts->uri.len = ruri->len;
+		contacts->dst_uri = msg->dst_uri;
+		contacts->sock = msg->force_send_socket;
+		getbflagsval(0, &contacts->flags);
+		contacts->path = msg->path_vec;
+	} else {
+		/* Insert first branch to first contact */
+		contacts->uri = uri;
+		contacts->dst_uri = dst_uri;
+		contacts->sock = sock;
+		contacts->flags = flags;
+		contacts->path = path;
+    }
+	contacts->q = first_q;
+	contacts->next = (struct contact *)0;
 
     /* Insert (remaining) branches to contact list in increasing q order */
 
_______________________________________________
sr-dev mailing list
sr-dev@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to