uac: new modparam reg_gc_interval
authorDaniel-Constantin Mierla <miconda@gmail.com>
Tue, 2 Jul 2019 16:30:48 +0000 (18:30 +0200)
committerDaniel-Constantin Mierla <miconda@gmail.com>
Tue, 2 Jul 2019 16:30:48 +0000 (18:30 +0200)
- defined value for garbage collection interval made configurable
- default value 150 (secs) - what was so far

src/modules/uac/uac.c
src/modules/uac/uac_reg.c

index 53a1b13..217d162 100644 (file)
@@ -107,6 +107,7 @@ static void mod_destroy(void);
 static int child_init(int rank);
 
 extern int reg_timer_interval;
+extern int _uac_reg_gc_interval;
 
 static pv_export_t mod_pvs[] = {
        { {"uac_req", sizeof("uac_req")-1}, PVT_OTHER, pv_get_uac_req, pv_set_uac_req,
@@ -170,6 +171,7 @@ static param_export_t params[] = {
        {"reg_keep_callid",     INT_PARAM,                      &reg_keep_callid       },
        {"reg_random_delay",    INT_PARAM,                      &reg_random_delay      },
        {"reg_active",  INT_PARAM,                      &reg_active_param      },
+       {"reg_gc_interval",             INT_PARAM,      &_uac_reg_gc_interval   },
        {0, 0, 0}
 };
 
index f75c7cf..dfc595f 100644 (file)
 #define UAC_REG_INIT           (1<<4) /* registration initialized */
 
 #define MAX_UACH_SIZE 2048
-#define UAC_REG_GC_INTERVAL    150
 #define UAC_REG_TM_CALLID_SIZE 90
 
+int _uac_reg_gc_interval = 150;
+
 typedef struct _reg_uac
 {
        unsigned int h_uuid;
@@ -423,9 +424,10 @@ int uac_reg_ht_shift(void)
        tn = time(NULL);
 
        lock_get(_reg_htable_gc_lock);
-       if(_reg_htable_gc->stime > tn-UAC_REG_GC_INTERVAL) {
+       if(_reg_htable_gc->stime > tn - _uac_reg_gc_interval) {
                lock_release(_reg_htable_gc_lock);
-               LM_ERR("shifting the memory table is not possible in less than %d secs\n", UAC_REG_GC_INTERVAL);
+               LM_ERR("shifting in-memory table is not possible in less than %d secs\n",
+                               _uac_reg_gc_interval);
                return -1;
        }
        uac_reg_reset_ht_gc();
@@ -1224,7 +1226,7 @@ void uac_reg_timer(unsigned int ticks)
        {
                lock_get(_reg_htable_gc_lock);
                if(_reg_htable_gc->stime!=0
-                               && _reg_htable_gc->stime < tn - UAC_REG_GC_INTERVAL)
+                               && _reg_htable_gc->stime < tn - _uac_reg_gc_interval)
                        uac_reg_reset_ht_gc();
                lock_release(_reg_htable_gc_lock);
        }