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

Author: Andrei Pelinescu-Onciul <[email protected]>
Committer: Andrei Pelinescu-Onciul <[email protected]>
Date:   Mon Mar  8 22:54:55 2010 +0100

tm: fix Reason generation for on-the-fly branch CANCELs

For a canceled transaction, branches that have not received any
reply might not have any pre-generated cancel buffers (in case
cancel_b_method!=2). This could also happen when the first
provisional response on a branch arrives in the same time with the
event triggering the cancel (e.g. 2xx or 6xx on another branch,
e2e cancel or timeout).
In this cases, when generating the per-branch CANCEL for the first
time (triggered by a received provisional reply), use the final
transaction reply code as Reason. Note that this covers only the
final reply triggered CANCEL case (2xx or 6xx received, local
timeout or local script t_reply()) and it does not cover the e2e
CANCEL case, for which either no reason will be generated
(cancel_b_method == 1) or the reason might be 487
(cancel_b_method==0).

---

 modules/tm/t_msgbuilder.c |    2 ++
 modules/tm/t_reply.c      |   10 ++++++++--
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/modules/tm/t_msgbuilder.c b/modules/tm/t_msgbuilder.c
index a05fdbc..91a82f0 100644
--- a/modules/tm/t_msgbuilder.c
+++ b/modules/tm/t_msgbuilder.c
@@ -171,6 +171,7 @@ char *build_local(struct cell *Trans,unsigned int branch,
        *len+=CONTENT_LENGTH_LEN+1 + CRLF_LEN;
        reason_len = 0;
        reas1 = 0;
+       reas_last = 0;
        /* compute reason size (if no reason or disabled => reason_len == 0)*/
        if (reason && reason->cause != CANCEL_REAS_UNKNOWN){
                if (likely(reason->cause > 0 &&
@@ -307,6 +308,7 @@ char *build_local_reparse(struct cell *Trans,unsigned int 
branch,
        
        reason_len = 0;
        reas1 = 0;
+       reas_last = 0;
        /* compute reason size (if no reason or disabled => reason_len == 0)*/
        if (reason && reason->cause != CANCEL_REAS_UNKNOWN){
                if (likely(reason->cause > 0 &&
diff --git a/modules/tm/t_reply.c b/modules/tm/t_reply.c
index 6ee3fae..6bcef61 100644
--- a/modules/tm/t_reply.c
+++ b/modules/tm/t_reply.c
@@ -2043,8 +2043,14 @@ int reply_received( struct sip_msg  *p_msg )
                                DBG("tm: reply_received: branch CANCEL 
created\n");
                                /* note that in this case we do not know the 
reason
                                   (it could be a final reply or a received 
cancel)
-                                  and we don't want to wait for it => no 
reason */
-                               cancel_branch(t, branch, 0, F_CANCEL_B_FORCE_C);
+                                  and we don't want to wait for it. However if
+                                  t->uas.status >= 200 it's probably due to a 
received
+                                  2xx, 6xx, local timeout or a local final 
reply 
+                                  (via t_reply()), so use t->uas.status as 
reason */
+                               cancel_data.reason.cause = 
(t->uas.status>=200)?t->uas.status:
+                                                                               
        CANCEL_REAS_UNKNOWN;
+                               cancel_branch(t, branch, &cancel_data.reason,
+                                                                               
                                F_CANCEL_B_FORCE_C);
                        }
                        goto done; /* nothing to do */
                }


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

Reply via email to