[sr-dev] git:kamailio_3.0: tm: auto-correct timeout values in K compat mode

Daniel-Constantin Mierla miconda at gmail.com
Mon Nov 2 15:20:21 CET 2009


Module: sip-router
Branch: kamailio_3.0
Commit: 2a34921ba091b10c201f330aa2f7bea336708231
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=2a34921ba091b10c201f330aa2f7bea336708231

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Mon Nov  2 15:16:16 2009 +0100

tm: auto-correct timeout values in K compat mode

- if the value of timer parameters is less than 120 then use T*1000
- SR TM use mili-seconds instead of seconds like in K 1.5
- print warning message if such case happens

---

 modules/tm/t_funcs.c |    7 +++++++
 modules/tm/timer.c   |   26 +++++++++++++++++++++++++-
 2 files changed, 32 insertions(+), 1 deletions(-)

diff --git a/modules/tm/t_funcs.c b/modules/tm/t_funcs.c
index 8b8a53a..988e22b 100644
--- a/modules/tm/t_funcs.c
+++ b/modules/tm/t_funcs.c
@@ -518,6 +518,13 @@ static inline int avp2timer(unsigned int* timer, int type, int_str name)
 		*timer = val_istr.n;
 	}
 
+	if(sr_cfg_compat==SR_COMPAT_KAMAILIO) {
+		if(*timer>0 && *timer<=120) {
+			LM_WARN("too small given timer value: %ums (using T*1000)\n",
+					*timer);
+			*timer *= 1000;
+		}
+	}
 	return *timer==0; /* 1 if 0 (use default), 0 if !=0 (use *timer) */
 }
 
diff --git a/modules/tm/timer.c b/modules/tm/timer.c
index 9c38274..ce9b7cd 100644
--- a/modules/tm/timer.c
+++ b/modules/tm/timer.c
@@ -131,7 +131,8 @@
 #include "../../parser/parser_f.h"
 #include "../../ut.h"
 #include "../../timer_ticks.h"
-#include "../../compiler_opt.h"
+#include "../../compiler_opt.h" 
+#include "../../sr_compat.h" 
 #include "t_funcs.h"
 #include "t_reply.h"
 #include "t_cancel.h"
@@ -173,6 +174,29 @@ struct msgid_var user_noninv_max_lifetime;
 /* fix timer values to ticks */
 int tm_init_timers()
 {
+	if(sr_cfg_compat==SR_COMPAT_KAMAILIO) {
+		if(default_tm_cfg.fr_timeout<=120) {
+			LM_WARN("too small given fr_timer value: %ums (using T*1000)\n",
+					default_tm_cfg.fr_timeout);
+			default_tm_cfg.fr_timeout *= 1000;
+		}
+		if(default_tm_cfg.fr_inv_timeout<=120) {
+			LM_WARN("too small given fr_inv_timer value: %ums (using T*1000)\n",
+					default_tm_cfg.fr_inv_timeout);
+			default_tm_cfg.fr_inv_timeout *= 1000;
+		}
+		if(default_tm_cfg.wait_timeout<=120) {
+			LM_WARN("too small given wait_timer value: %ums (using T*1000)\n",
+					default_tm_cfg.wait_timeout);
+			default_tm_cfg.wait_timeout *= 1000;
+		}
+		if(default_tm_cfg.delete_timeout<=120) {
+			LM_WARN("too small given delete_timer value: %ums (using T*1000)\n",
+					default_tm_cfg.delete_timeout);
+			default_tm_cfg.delete_timeout *= 1000;
+		}
+	}
+
 	default_tm_cfg.fr_timeout=MS_TO_TICKS(default_tm_cfg.fr_timeout); 
 	default_tm_cfg.fr_inv_timeout=MS_TO_TICKS(default_tm_cfg.fr_inv_timeout);
 	default_tm_cfg.wait_timeout=MS_TO_TICKS(default_tm_cfg.wait_timeout);




More information about the sr-dev mailing list