فهرست منبع

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).
Andrei Pelinescu-Onciul 15 سال پیش
والد
کامیت
e85232164c
2فایلهای تغییر یافته به همراه10 افزوده شده و 2 حذف شده
  1. 2 0
      modules/tm/t_msgbuilder.c
  2. 8 2
      modules/tm/t_reply.c

+ 2 - 0
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;
 	*len+=CONTENT_LENGTH_LEN+1 + CRLF_LEN;
 	reason_len = 0;
 	reason_len = 0;
 	reas1 = 0;
 	reas1 = 0;
+	reas_last = 0;
 	/* compute reason size (if no reason or disabled => reason_len == 0)*/
 	/* compute reason size (if no reason or disabled => reason_len == 0)*/
 	if (reason && reason->cause != CANCEL_REAS_UNKNOWN){
 	if (reason && reason->cause != CANCEL_REAS_UNKNOWN){
 		if (likely(reason->cause > 0 &&
 		if (likely(reason->cause > 0 &&
@@ -307,6 +308,7 @@ char *build_local_reparse(struct cell *Trans,unsigned int branch,
 	
 	
 	reason_len = 0;
 	reason_len = 0;
 	reas1 = 0;
 	reas1 = 0;
+	reas_last = 0;
 	/* compute reason size (if no reason or disabled => reason_len == 0)*/
 	/* compute reason size (if no reason or disabled => reason_len == 0)*/
 	if (reason && reason->cause != CANCEL_REAS_UNKNOWN){
 	if (reason && reason->cause != CANCEL_REAS_UNKNOWN){
 		if (likely(reason->cause > 0 &&
 		if (likely(reason->cause > 0 &&

+ 8 - 2
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");
 				DBG("tm: reply_received: branch CANCEL created\n");
 				/* note that in this case we do not know the reason
 				/* note that in this case we do not know the reason
 				   (it could be a final reply or a received cancel)
 				   (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 */
 			goto done; /* nothing to do */
 		}
 		}