Prechádzať zdrojové kódy

tm: re-added the option for no-internal reply on error

- new function t_set_disable_internal_reply(0|1) to disable|enable this
  option per transaction
- t_relay_to() flags re-enabled for this option
- backport of 0f2f9c85eff0b6ad35b4c58dfcde74c8a65559d6
Daniel-Constantin Mierla 12 rokov pred
rodič
commit
3d836040bd
3 zmenil súbory, kde vykonal 20 pridanie a 4 odobranie
  1. 2 0
      modules/tm/h_table.h
  2. 9 0
      modules/tm/t_funcs.c
  3. 9 4
      modules/tm/tm.c

+ 2 - 0
modules/tm/h_table.h

@@ -299,6 +299,8 @@ struct totag_elem {
 #	define pass_provisional(_t_)	((_t_)->flags&T_PASS_PROVISIONAL_FLAG)
 #endif
 
+#define T_DISABLE_INTERNAL_REPLY (1<<12) /* don't send internal negative reply */
+
 /* unsigned short should be enough for a retr. timer: max. 65535 ms =>
  * max retr. = 65 s which should be enough and saves us 2*2 bytes */
 typedef unsigned short retr_timeout_t;

+ 9 - 0
modules/tm/t_funcs.c

@@ -358,6 +358,15 @@ handle_ret:
 		/* we don't want to pass upstream any reply regarding replicating
 		 * a request; replicated branch must stop at us*/
 		if (likely(!replicate)) {
+			if(t->flags&T_DISABLE_INTERNAL_REPLY) {
+				/* flag set to don't generate the internal negative reply
+				 * - let the transaction live further, processing should
+				 *   continue in config */
+				DBG("not generating immediate reply for error %d\n", ser_error);
+				tm_error=ser_error;
+				ret = -4;
+				goto done;
+			}
 #ifdef TM_DELAYED_REPLY
 			/* current error in tm_error */
 			tm_error=ser_error;

+ 9 - 4
modules/tm/tm.c

@@ -289,6 +289,7 @@ static int t_set_disable_failover(struct sip_msg* msg, char* on_off, char* f);
 static int t_set_no_e2e_cancel_reason(struct sip_msg* msg, char* on_off,
 										char* f);
 #endif /* CANCEL_REASON_SUPPORT */
+static int t_set_disable_internal_reply(struct sip_msg* msg, char* on_off, char* f);
 static int t_branch_timeout(struct sip_msg* msg, char*, char*);
 static int t_branch_replied(struct sip_msg* msg, char*, char*);
 static int t_any_timeout(struct sip_msg* msg, char*, char*);
@@ -448,6 +449,8 @@ static cmd_export_t cmds[]={
 		fixup_var_int_1,
 			REQUEST_ROUTE|TM_ONREPLY_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE },
 #endif /* CANCEL_REASON_SUPPORT */
+	{"t_set_disable_internal_reply", t_set_disable_internal_reply, 1, fixup_var_int_1,
+			REQUEST_ROUTE|TM_ONREPLY_ROUTE|FAILURE_ROUTE|BRANCH_ROUTE },
 	{"t_branch_timeout",  t_branch_timeout,         0, 0,  FAILURE_ROUTE},
 	{"t_branch_replied",  t_branch_replied,         0, 0,  FAILURE_ROUTE},
 	{"t_any_timeout",     t_any_timeout,            0, 0, 
@@ -1827,6 +1830,10 @@ T_SET_FLAG_GEN_FUNC(t_set_no_e2e_cancel_reason, T_NO_E2E_CANCEL_REASON)
 #endif /* CANCEL_REASON_SUPPORT */
 
 
+/* disable internal negative reply for the current transaction */
+T_SET_FLAG_GEN_FUNC(t_set_disable_internal_reply, T_DISABLE_INTERNAL_REPLY)
+
+
 /* script function, FAILURE_ROUTE only, returns true if the 
  * choosed "failure" branch failed because of a timeout, 
  * -1 otherwise */
@@ -2220,13 +2227,11 @@ inline static int w_t_relay_to(struct sip_msg *msg, char *proxy, char *flags)
 			param.v.i = 0;
 			t_set_auto_inv_100(msg, (char*)(&param), 0);
 		}
-		/* no auto negative reply - not implemented */
-		/*
+		/* no auto negative reply */
 		if(fl&2) {
 			param.v.i = 1;
-			t_set_disable_internal_reply(msg, (char*)param, 0);
+			t_set_disable_internal_reply(msg, (char*)(&param), 0);
 		}
-		*/
 		/* no dns failover */
 		if(fl&4) {
 			param.v.i = 1;