Переглянути джерело

- more simple way of setting on_reply and failure routes;
- bug in setting these routes from failure_route

Bogdan-Andrei Iancu 21 роки тому
батько
коміт
7a60138754
3 змінених файлів з 32 додано та 54 видалено
  1. 0 6
      modules/tm/t_fwd.c
  2. 26 6
      modules/tm/t_reply.c
  3. 6 42
      modules/tm/tm.c

+ 0 - 6
modules/tm/t_fwd.c

@@ -465,12 +465,6 @@ int t_forward_nonack( struct cell *t, struct sip_msg* p_msg ,
 		return lowest_ret;
 	}
 
-	/* store script processing value of failure route to transactional
-	   context; if currently 0, this forwarding attempt will no longer 
-	   result in failure_route on error
-	*/
-	t->on_negative=get_on_negative();
-
 	/* send them out now */
 	success_branch=0;
 	for (i=first_branch; i<t->nr_of_outgoings; i++) {

+ 26 - 6
modules/tm/t_reply.c

@@ -113,16 +113,33 @@ static int goto_on_reply=0;
    *inside*  t_relay using hints stored in private memory
    before t_reay is called
 */
-  
-  
+
+
 void t_on_negative( unsigned int go_to )
 {
-	goto_on_negative=go_to;
+	struct cell *t = get_t();
+
+	/* in MODE_REPLY and MODE_ONFAILURE T will be set to current transaction;
+	 * in MODE_REQUEST T will be set only if the transaction was already 
+	 * created; if not -> use the static variable */
+	if (!t || t==T_UNDEFINED )
+		goto_on_negative=go_to;
+	else
+		get_t()->on_negative = go_to;
 }
 
+
 void t_on_reply( unsigned int go_to )
 {
-	goto_on_reply=go_to;
+	struct cell *t = get_t();
+
+	/* in MODE_REPLY and MODE_ONFAILURE T will be set to current transaction;
+	 * in MODE_REQUEST T will be set only if the transaction was already 
+	 * created; if not -> use the static variable */
+	if (!t || t==T_UNDEFINED )
+		goto_on_reply=go_to;
+	else
+		get_t()->on_reply = go_to;
 }
 
 
@@ -428,6 +445,7 @@ static inline int run_failure_handlers(struct cell *t, struct sip_msg *rpl,
 {
 	static struct sip_msg fake_req;
 	struct sip_msg *shmem_msg = t->uas.request;
+	int on_failure;
 
 	/* failure_route for a local UAC? */
 	if (!shmem_msg) {
@@ -497,9 +515,11 @@ static inline int run_failure_handlers(struct cell *t, struct sip_msg *rpl,
 		/* avoid recursion -- if failure_route forwards, and does not 
 		 * set next failure route, failure_route will not be rentered
 		 * on failure */
-		t_on_negative(0);
+		//goto_on_negative = 0;
+		on_failure = t->on_negative;
+		t->on_negative=0;
 		/* run a reply_route action if some was marked */
-		if (run_actions(failure_rlist[t->on_negative], &fake_req)<0)
+		if (run_actions(failure_rlist[on_failure], &fake_req)<0)
 			LOG(L_ERR, "ERROR: run_failure_handlers: Error in do_action\n");
 	}
 

+ 6 - 42
modules/tm/tm.c

@@ -728,58 +728,22 @@ inline static int w_t_retransmit_reply( struct sip_msg* p_msg, char* foo, char*
 inline static int w_t_newtran( struct sip_msg* p_msg, char* foo, char* bar ) 
 {
 	/* t_newtran returns 0 on error (negative value means
-	   'transaction exists'
-	*/
+	   'transaction exists' */
 	return t_newtran( p_msg );
 }
 
 
-inline static int w_t_on_negative( struct sip_msg* msg, char *go_to, char *foo )
+inline static int w_t_on_negative( struct sip_msg* msg, char *go_to, char *foo)
 {
-	struct cell *t;
-
-	if (rmode==MODE_REQUEST || rmode==MODE_ONFAILURE) {
-		t_on_negative( (unsigned int )(long) go_to );
-		return 1;
-	}
-	if (rmode==MODE_ONREPLY ) {
-		/* transaction state is established */
-		t=get_t();
-		if (!t || t==T_UNDEFINED) {
-			LOG(L_CRIT, "BUG: w_t_on_negative entered without t\n");
-			return -1;
-		}
-		t->on_negative=(unsigned int)(long)go_to;
-		return 1;
-	}
-	LOG(L_CRIT, "BUG: w_t_on_negative entered in unsupported mode\n");
-	return -1;
+	t_on_negative( (unsigned int )(long) go_to );
+	return 1;
 }
 
 
 inline static int w_t_on_reply( struct sip_msg* msg, char *go_to, char *foo )
 {
-	struct cell *t;
-
-	if (rmode==MODE_REQUEST) {
-		/* it's still in initial request processing stage, transaction
-		 * state is not estabslihed yet, store it in private memory ...
-		 * it will be copied to transaction state when it is set up */
-		t_on_reply( (unsigned int )(long) go_to );
-		return 1;
-	}
-	if (rmode==MODE_ONREPLY || rmode==MODE_ONFAILURE) {
-		/* transaction state is established */
-		t=get_t();
-		if (!t || t==T_UNDEFINED) {
-			LOG(L_CRIT, "BUG: w_t_on_reply entered without t\n");
-			return -1;
-		}
-		t->on_reply=(unsigned int) (long)go_to;
-		return 1;
-	}
-	LOG(L_CRIT, "BUG: w_t_on_reply entered in unsupported mode\n");
-	return -1;
+	t_on_reply( (unsigned int )(long) go_to );
+	return 1;
 }