From 926a97f4eb741401b193fb711e6c439555c646ab Mon Sep 17 00:00:00 2001 From: Marco Capetta Date: Mon, 6 May 2019 11:07:44 +0200 Subject: [PATCH] dialplan: add reload_delta parameter - make the rate limit of maximum allowed dialplan reload configurable using the new 'reload_delta' paramenter. --- src/modules/dialplan/dialplan.c | 7 ++++- src/modules/dialplan/doc/dialplan_admin.xml | 32 +++++++++++++++++++-- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/modules/dialplan/dialplan.c b/src/modules/dialplan/dialplan.c index d8685d52f2b..20b7744e219 100644 --- a/src/modules/dialplan/dialplan.c +++ b/src/modules/dialplan/dialplan.c @@ -87,6 +87,7 @@ dp_param_p default_par2 = NULL; int dp_fetch_rows = 1000; int dp_match_dynamic = 0; int dp_append_branch = 1; +int dp_reload_delta = 5; static time_t *dp_rpc_reload_time = NULL; @@ -105,6 +106,7 @@ static param_export_t mod_params[]={ { "fetch_rows", PARAM_INT, &dp_fetch_rows }, { "match_dynamic", PARAM_INT, &dp_match_dynamic }, { "append_branch", PARAM_INT, &dp_append_branch }, + { "reload_delta", PARAM_INT, &dp_reload_delta }, {0,0,0} }; @@ -182,6 +184,9 @@ static int mod_init(void) if(dp_fetch_rows<=0) dp_fetch_rows = 1000; + if(dp_reload_delta<0) + dp_reload_delta = 5; + if(init_data() != 0) { LM_ERR("could not initialize data\n"); return -1; @@ -619,7 +624,7 @@ static void dialplan_rpc_reload(rpc_t* rpc, void* ctx) rpc->fault(ctx, 500, "Not ready for reload"); return; } - if(*dp_rpc_reload_time!=0 && *dp_rpc_reload_time > time(NULL) - 5) { + if(*dp_rpc_reload_time!=0 && *dp_rpc_reload_time > time(NULL) - dp_reload_delta) { LM_ERR("ongoing reload\n"); rpc->fault(ctx, 500, "ongoing reload"); return; diff --git a/src/modules/dialplan/doc/dialplan_admin.xml b/src/modules/dialplan/doc/dialplan_admin.xml index 371120fac47..e524524fb8b 100644 --- a/src/modules/dialplan/doc/dialplan_admin.xml +++ b/src/modules/dialplan/doc/dialplan_admin.xml @@ -410,6 +410,33 @@ modparam("dialplan", "append_branch", 0) +
+ <varname>reload_delta</varname> (int) + + The number of seconds that have to be waited before executing a new reload + of dialplan rules. By default there is a rate limiting of maximum one reload + in five seconds. + + + If set to 0, no rate limit is configured. Note carefully: use this configuration + only in tests environments because executing two dialplan reloads at the same + time can cause to kamailio to crash. + + + + Default value is 5. + + + + Set <varname>reload_delta</varname> parameter + +... +modparam("dialplan", "reload_delta", 1) +... + + +
+ @@ -620,8 +647,9 @@ xlog("translated to var $var(y) \n"); dp_reload() - Reload the translation rules from the database. Note that there is - a rate limiting of maximum one reload in five seconds. + Reload the translation rules from the database. Note that there is a + rate limiting defined by 'reload_delta' paramenter. By default is allowed + maximum one reload in five seconds. Name: dp_reload