tm: auto-correct timeout values in K compat mode
authorDaniel-Constantin Mierla <miconda@gmail.com>
Mon, 2 Nov 2009 14:16:16 +0000 (15:16 +0100)
committerAndrei Pelinescu-Onciul <andrei@iptel.org>
Fri, 15 Jan 2010 11:41:43 +0000 (12:41 +0100)
- 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
(cherry picked from commit 2a34921ba091b10c201f330aa2f7bea336708231)

modules/tm/t_funcs.c
modules/tm/timer.c

index 8b8a53a..988e22b 100644 (file)
@@ -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) */
 }
 
index 9c38274..ce9b7cd 100644 (file)
 #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);