浏览代码

- some updates in t_check_status() - Jiri's suggestion to use directly the
t_pick_branch() in FAILURE mode

Bogdan-Andrei Iancu 22 年之前
父节点
当前提交
b32cfb35f7
共有 3 个文件被更改,包括 10 次插入8 次删除
  1. 2 3
      modules/tm/t_reply.c
  2. 4 0
      modules/tm/t_reply.h
  3. 4 5
      modules/tm/tm.c

+ 2 - 3
modules/tm/t_reply.c

@@ -528,8 +528,7 @@ int failure_route(struct cell *t)
  * -1   ... error
  * -2   ... can't decide yet -- incomplete branches present
  */
-static int pick_branch( int inc_branch, int inc_code, 
-			struct cell *t, int *res_code)
+int t_pick_branch(int inc_branch, int inc_code, struct cell *t, int *res_code)
 {
 	int lowest_b, lowest_s, b;
 
@@ -618,7 +617,7 @@ static enum rps t_should_relay_response( struct cell *Trans , int new_code,
 		Trans->uac[branch].last_received=new_code;
 
 		/* if all_final return lowest */
-		picked_branch=pick_branch(branch,new_code, Trans, &picked_code);
+		picked_branch=t_pick_branch(branch,new_code, Trans, &picked_code);
 		if (picked_branch==-2) { /* branches open yet */
 			*should_store=1;
 			*should_relay=-1;

+ 4 - 0
modules/tm/t_reply.h

@@ -138,5 +138,9 @@ int t_retransmit_reply( struct cell *t );
 
 void tm_init_tags();
 
+/* selects the branch for fwd-ing the reply */
+int t_pick_branch(int inc_branch, int inc_code, struct cell *t, int *res_code);
+
+
 #endif
 

+ 4 - 5
modules/tm/tm.c

@@ -542,11 +542,10 @@ static int t_check_status(struct sip_msg* msg, char *regexp, char *foo)
 			break;
 		case MODE_ONFAILURE:
 			/* use the status of the winning reply */
-			lowest_status=999;
-			for ( n=0; n<t->nr_of_outgoings ; n++ ) {
-				if ( t->uac[n].last_received<lowest_status ) {
-					lowest_status = t->uac[n].last_received;
-				}
+			if (t_pick_branch( -1, 0, t, &lowest_status)<0 ) {
+				LOG(L_CRIT,"BUG:t_check_status: t_pick_branch failed to get "
+					" a final response in MODE_ONFAILURE\n");
+				return -1;
 			}
 			status = int2str( lowest_status , 0);
 			break;