Add a safe way to reload extensions config (don't change/delete the current extenions until extensions.conf was parsed and the new set of extensions is created) and add "extensions reload" CLI command so we could reload only extensions.conf config file without touching config files of other modules

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1183 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.0
Martin Pycko 22 years ago
parent 37f1d9add6
commit cbd33586ac

@ -118,6 +118,7 @@ int pbx_exec(struct ast_channel *c, struct ast_app *app, void *data, int newstac
//! Register a new context
/*!
* \param extcontexts pointer to the ast_context structure pointer
* \param name name of the new context
* \param registrar registrar of the context
* This will first search for a context with your name. If it exists already, it will not
@ -125,7 +126,13 @@ int pbx_exec(struct ast_channel *c, struct ast_app *app, void *data, int newstac
* and registrar.
* It returns NULL on failure, and an ast_context structure on success
*/
struct ast_context *ast_context_create(char *name, char *registrar);
struct ast_context *ast_context_create(struct ast_context **extcontexts, char *name, char *registrar);
//! Merge the temporary contexts into a global contexts list and delete from the global list the ones that are being added
/*!
* \param extcontexts pointer to the ast_context structure pointer
*/
void ast_merge_contexts_and_delete(struct ast_context **extcontexts);
//! Destroy a context (matches the specified context (or ANY context if NULL)
/*!

@ -44,6 +44,8 @@ static int write_protect_config = 1;
static pthread_mutex_t save_dialplan_lock = AST_MUTEX_INITIALIZER;
static struct ast_context *local_contexts = NULL;
/*
* Help for commands provided by this module ...
*/
@ -89,6 +91,12 @@ static char context_remove_ignorepat_help[] =
"\n"
"Example: remove ignorepat _3XX from local\n";
static char reload_extensions_help[] =
"Usage: reload extensions.conf without reloading any other modules\n"
" This command does not delete global variables\n"
"\n"
"Example: reload extensions\n";
/*
* Implementation of functions provided by this module
*/
@ -1337,6 +1345,15 @@ static int handle_context_remove_ignorepat(int fd, int argc, char *argv[])
return RESULT_SUCCESS;
}
static int pbx_load_module(void);
static int handle_reload_extensions(int fd, int argc, char *argv[])
{
if (argc!=2) return RESULT_SHOWUSAGE;
pbx_load_module();
return RESULT_SUCCESS;
}
static char *complete_context_remove_ignorepat(char *line, char *word,
int pos, int state)
{
@ -1492,6 +1509,10 @@ static struct ast_cli_entry context_remove_ignorepat_cli =
"Remove ignore pattern from context", context_remove_ignorepat_help,
complete_context_remove_ignorepat };
static struct ast_cli_entry reload_extensions_cli =
{ { "extensions", "reload", NULL}, handle_reload_extensions,
"Reload extensions and *only* extensions", reload_extensions_help };
/*
* Standard module functions ...
*/
@ -1505,6 +1526,7 @@ int unload_module(void)
ast_cli_unregister(&context_remove_extension_cli);
ast_cli_unregister(&context_remove_ignorepat_cli);
ast_cli_unregister(&context_add_ignorepat_cli);
ast_cli_unregister(&reload_extensions_cli);
ast_context_destroy(NULL, registrar);
return 0;
}
@ -1536,7 +1558,7 @@ static int pbx_load_module(void)
cxt = ast_category_browse(cfg, cxt);
continue;
}
if ((con=ast_context_create(cxt, registrar))) {
if ((con=ast_context_create(&local_contexts,cxt, registrar))) {
v = ast_variable_browse(cfg, cxt);
while(v) {
if (!strcasecmp(v->name, "exten")) {
@ -1619,6 +1641,7 @@ static int pbx_load_module(void)
}
ast_destroy(cfg);
}
ast_merge_contexts_and_delete(&local_contexts);
return 0;
}
@ -1634,6 +1657,7 @@ int load_module(void)
ast_cli_register(&context_add_extension_cli);
ast_cli_register(&context_add_ignorepat_cli);
ast_cli_register(&context_remove_ignorepat_cli);
ast_cli_register(&reload_extensions_cli);
return 0;
}

@ -633,7 +633,7 @@ int load_module(void)
}
con = ast_context_find(parking_con);
if (!con) {
con = ast_context_create(parking_con, registrar);
con = ast_context_create(NULL,parking_con, registrar);
if (!con) {
ast_log(LOG_ERROR, "Parking context '%s' does not exist and unable to create\n", parking_con);
return -1;

Loading…
Cancel
Save