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

Author: Daniel-Constantin Mierla <[email protected]>
Committer: Daniel-Constantin Mierla <[email protected]>
Date: 2018-10-17T08:51:50+02:00

pipelimit: execute timer routine per timer_interval

- reported by GH #1675 and GH #1671

---

Modified: src/modules/pipelimit/pipelimit.c
Modified: src/modules/pipelimit/pl_ht.c

---

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

---

diff --git a/src/modules/pipelimit/pipelimit.c 
b/src/modules/pipelimit/pipelimit.c
index 716938991a..c3cbf56103 100644
--- a/src/modules/pipelimit/pipelimit.c
+++ b/src/modules/pipelimit/pipelimit.c
@@ -64,7 +64,7 @@ MODULE_VERSION
 /*
  * timer interval length in seconds, tunable via modparam
  */
-#define PL_TIMER_INTERVAL 10
+#define PL_TIMER_INTERVAL_DEFAULT 10
 
 /** SL API structure */
 sl_api_t slb;
@@ -85,10 +85,10 @@ static str pl_drop_reason = str_init("Server Unavailable");
 static int pl_hash_size = 6;
 
 typedef struct pl_queue {
-       int     *       pipe;
-       int             pipe_mp;
-       str     *       method;
-       str             method_mp;
+       int *pipe;
+       int pipe_mp;
+       str *method;
+       str method_mp;
 } pl_queue_t;
 
 static struct timer_ln* pl_timer;
@@ -107,7 +107,7 @@ static int load_source_mp = LOAD_SOURCE_CPU;
 static int * load_source;
 
 /* these only change in the mod_init() process -- no locking needed */
-static int timer_interval = PL_TIMER_INTERVAL;
+static int pl_timer_interval = PL_TIMER_INTERVAL_DEFAULT;
 int _pl_cfg_setpoint;        /* desired load, used when reading modparams */
 /* === */
 
@@ -137,7 +137,7 @@ static cmd_export_t cmds[]={
        {0,0,0,0,0,0}
 };
 static param_export_t params[]={
-       {"timer_interval",       INT_PARAM,          &timer_interval},
+       {"timer_interval",       INT_PARAM,          &pl_timer_interval},
        {"reply_code",           INT_PARAM,          &pl_drop_code},
        {"reply_reason",         PARAM_STR,          &pl_drop_reason},
        {"db_url",               PARAM_STR,          &pl_db_url},
@@ -346,7 +346,8 @@ static int mod_init(void)
                return -1;
        }
        timer_init(pl_timer, pl_timer_handle, 0, F_TIMER_FAST);
-       timer_add(pl_timer, MS_TO_TICKS(1000)); /* Start it after 1000ms */
+       /* execute timer routine after pl_timer_interval * 1000ms */
+       timer_add(pl_timer, pl_timer_interval * MS_TO_TICKS(1000));
 
        /* bind the SL API */
        if (sl_load_api(&slb)!=0) {
@@ -723,7 +724,7 @@ static ticks_t pl_timer_handle(ticks_t ticks, struct 
timer_ln* tl, void* data)
 
        *network_load_value = get_total_bytes_waiting();
 
-       pl_pipe_timer_update(timer_interval, *network_load_value);
+       pl_pipe_timer_update(pl_timer_interval, *network_load_value);
 
        return (ticks_t)(-1); /* periodical */
 }
diff --git a/src/modules/pipelimit/pl_ht.c b/src/modules/pipelimit/pl_ht.c
index fa2c9c5ad0..518254f1fa 100644
--- a/src/modules/pipelimit/pl_ht.c
+++ b/src/modules/pipelimit/pl_ht.c
@@ -345,7 +345,7 @@ void pl_pipe_timer_update(int interval, int netload)
                                if( it->algo == PIPE_ALGO_NETWORK ) {
                                        it->load = ( netload > it->limit ) ? 1 
: -1;
                                } else if (it->limit && interval) {
-                                       it->load = it->counter / (it->limit * 
interval);
+                                       it->load = it->counter / it->limit;
                                }
                                it->last_counter = it->counter;
                                it->counter = 0;


_______________________________________________
Kamailio (SER) - Development Mailing List
[email protected]
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to