Module: kamailio
Branch: master
Commit: 76c273ecaa76f031ce9892acd895b4eacf4de17e
URL:
https://github.com/kamailio/kamailio/commit/76c273ecaa76f031ce9892acd895b4e…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2022-01-24T13:37:36+01:00
dispatcher: check reload delta in functions building new routing structure
---
Modified: src/modules/dispatcher/dispatcher.c
---
Diff:
https://github.com/kamailio/kamailio/commit/76c273ecaa76f031ce9892acd895b4e…
Patch:
https://github.com/kamailio/kamailio/commit/76c273ecaa76f031ce9892acd895b4e…
---
diff --git a/src/modules/dispatcher/dispatcher.c b/src/modules/dispatcher/dispatcher.c
index 37000221e3..059df89123 100644
--- a/src/modules/dispatcher/dispatcher.c
+++ b/src/modules/dispatcher/dispatcher.c
@@ -952,6 +952,16 @@ static int ds_warn_fixup(void **param, int param_no)
static int ds_reload(sip_msg_t *msg)
{
+ if(ds_rpc_reload_time==NULL) {
+ LM_ERR("not ready for reload\n");
+ return -1;
+ }
+ if(*ds_rpc_reload_time!=0 && *ds_rpc_reload_time > time(NULL) -
ds_reload_delta) {
+ LM_ERR("ongoing reload\n");
+ return -1;
+ }
+ *ds_rpc_reload_time = time(NULL);
+
if(!ds_db_url.s) {
if(ds_load_list(dslistfile) != 0)
LM_ERR("Error reloading from list\n");
@@ -1859,6 +1869,18 @@ static void dispatcher_rpc_add(rpc_t *rpc, void *ctx)
str dest;
str attrs = STR_NULL;
+ if(ds_rpc_reload_time==NULL) {
+ LM_ERR("Not ready for rebuilding destinations list\n");
+ rpc->fault(ctx, 500, "Not ready for reload");
+ return;
+ }
+ if(*ds_rpc_reload_time!=0 && *ds_rpc_reload_time > time(NULL) -
ds_reload_delta) {
+ LM_ERR("ongoing reload\n");
+ rpc->fault(ctx, 500, "Ongoing reload");
+ return;
+ }
+ *ds_rpc_reload_time = time(NULL);
+
flags = 0;
nparams = rpc->scan(ctx, "dS*dS", &group, &dest, &flags,
&attrs);
@@ -1890,6 +1912,18 @@ static void dispatcher_rpc_remove(rpc_t *rpc, void *ctx)
int group;
str dest;
+ if(ds_rpc_reload_time==NULL) {
+ LM_ERR("Not ready for rebuilding destinations list\n");
+ rpc->fault(ctx, 500, "Not ready for reload");
+ return;
+ }
+ if(*ds_rpc_reload_time!=0 && *ds_rpc_reload_time > time(NULL) -
ds_reload_delta) {
+ LM_ERR("ongoing reload\n");
+ rpc->fault(ctx, 500, "Ongoing reload");
+ return;
+ }
+ *ds_rpc_reload_time = time(NULL);
+
if(rpc->scan(ctx, "dS", &group, &dest) < 2) {
rpc->fault(ctx, 500, "Invalid Parameters");
return;