Skip to content

Commit

Permalink
Run cfg validation (by modules) at cfg reload
Browse files Browse the repository at this point in the history
  • Loading branch information
bogdan-iancu committed Apr 12, 2019
1 parent 1896689 commit 4a85d5b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cfg_reload.c
Expand Up @@ -425,8 +425,12 @@ int reload_routing_script(void)
goto error;
}

/* TODO - trigger module's callbacks to check if the reload of this
/* trigger module's validation functions to check if the reload of this
* new route set is "approved" */
if (!modules_validate_reload()) {
LM_ERR("routes validation by modules failed, abording\n");
goto error;
}

/* we do not need the cfg, so free it and restore previous set of routes */
sroutes = sr_bk;
Expand Down
20 changes: 20 additions & 0 deletions sr_module.c
Expand Up @@ -811,3 +811,23 @@ int start_module_procs(void)

return 0;
}


int modules_validate_reload(void)
{
struct sr_module *m;
int ret = 1;

for( m=modules ; m ; m=m->next) {
if (m->exports->reload_ack_f==NULL)
continue;
if (!m->exports->reload_ack_f()) {
LM_ERR("module <%s> did not validated the cfg file\n",
m->exports->name);
ret = 0;
}
}

return ret;
}

2 changes: 2 additions & 0 deletions sr_module.h
Expand Up @@ -256,5 +256,7 @@ int count_module_procs(int flags);
/*! \brief Forks and starts the additional processes required by modules */
int start_module_procs(void);

/*! \brief Runs the reload validation function from all modules */
int modules_validate_reload(void);

#endif

0 comments on commit 4a85d5b

Please sign in to comment.