Module: kamailio
Branch: master
Commit: bb2c365340b9354eae85b375f116894192e65c22
URL: 
https://github.com/kamailio/kamailio/commit/bb2c365340b9354eae85b375f116894192e65c22

Author: Stefan Mititelu <stefan.mitit...@net2phone.com>
Committer: Daniel-Constantin Mierla <mico...@gmail.com>
Date: 2025-08-08T12:59:42+02:00

core: add timer_sanity_check coreparam

---

Modified: src/core/coreparam.c
Modified: src/core/timer.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/bb2c365340b9354eae85b375f116894192e65c22.diff
Patch: 
https://github.com/kamailio/kamailio/commit/bb2c365340b9354eae85b375f116894192e65c22.patch

---

diff --git a/src/core/coreparam.c b/src/core/coreparam.c
index d8e3287c2c7..e1e362c5fd4 100644
--- a/src/core/coreparam.c
+++ b/src/core/coreparam.c
@@ -25,12 +25,14 @@
 #include "coreparam.h"
 
 int ksr_coreparam_store_nval(str *pname, ksr_cpval_t *pval, void *eparam);
+long ksr_timer_sanity_check = 0;
 
 /* clang-format off */
 static ksr_cpexport_t _ksr_cpexports[] = {
        { str_init("random_engine"), KSR_CPTYPE_STR,
                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 }
 };
 /* clang-format on */
diff --git a/src/core/timer.c b/src/core/timer.c
index 8375691cc9a..615caa1edf8 100644
--- a/src/core/timer.c
+++ b/src/core/timer.c
@@ -58,6 +58,8 @@
 #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 last_ticks;        /* last time we adjusted the time */
 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
        // 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();
        }
 

_______________________________________________
Kamailio - Development Mailing List -- sr-dev@lists.kamailio.org
To unsubscribe send an email to sr-dev-le...@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the 
sender!

Reply via email to