2
0
Эх сурвалжийг харах

core: add timer_sanity_check coreparam

Stefan Mititelu 1 сар өмнө
parent
commit
bb2c365340

+ 3 - 1
src/core/coreparam.c

@@ -25,12 +25,14 @@
 #include "coreparam.h"
 #include "coreparam.h"
 
 
 int ksr_coreparam_store_nval(str *pname, ksr_cpval_t *pval, void *eparam);
 int ksr_coreparam_store_nval(str *pname, ksr_cpval_t *pval, void *eparam);
+long ksr_timer_sanity_check = 0;
 
 
 /* clang-format off */
 /* clang-format off */
 static ksr_cpexport_t _ksr_cpexports[] = {
 static ksr_cpexport_t _ksr_cpexports[] = {
 	{ str_init("random_engine"), KSR_CPTYPE_STR,
 	{ str_init("random_engine"), KSR_CPTYPE_STR,
 		ksr_xrand_cp, NULL },
 		ksr_xrand_cp, NULL },
-
+	{ str_init("timer_sanity_check"), KSR_CPTYPE_NUM,
+		ksr_coreparam_store_nval, &ksr_timer_sanity_check },
 	{ {0, 0}, 0, NULL, NULL }
 	{ {0, 0}, 0, NULL, NULL }
 };
 };
 /* clang-format on */
 /* clang-format on */

+ 4 - 1
src/core/timer.c

@@ -58,6 +58,8 @@
 #define TIMER_MAX_DRIFT (TIMER_TICKS_HZ / 10U)	 /* if drift > 0.1s adjust */
 #define TIMER_MAX_DRIFT (TIMER_TICKS_HZ / 10U)	 /* if drift > 0.1s adjust */
 
 
 
 
+extern long ksr_timer_sanity_check;
+
 static ticks_t *ticks = 0;
 static ticks_t *ticks = 0;
 static ticks_t last_ticks;	   /* last time we adjusted the time */
 static ticks_t last_ticks;	   /* last time we adjusted the time */
 static ticks_t last_adj_check; /* last time we ran adjust_ticks */
 static ticks_t last_adj_check; /* last time we ran adjust_ticks */
@@ -892,7 +894,8 @@ inline static void timer_list_expire(ticks_t t, struct timer_head *h
 
 
 	// check if timer circular double linked list has broken links
 	// check if timer circular double linked list has broken links
 	// try to recover if so, otherwise abort execution
 	// try to recover if so, otherwise abort execution
-	if(!timer_list_sanity_check(h)) {
+	LM_DBG("ksr_timer_sanity_check = %ld\n", ksr_timer_sanity_check);
+	if(ksr_timer_sanity_check != 0 && !timer_list_sanity_check(h)) {
 		abort();
 		abort();
 	}
 	}