aboutsummaryrefslogtreecommitdiffstats
path: root/pbx
diff options
context:
space:
mode:
authormartinp <martinp@f38db490-d61c-443f-a65b-d21fe96a405b>2003-07-14 15:33:21 +0000
committermartinp <martinp@f38db490-d61c-443f-a65b-d21fe96a405b>2003-07-14 15:33:21 +0000
commitcf44999a3e2a575c4f6d18cdb3919f77da5dc8e5 (patch)
treea3ee7cd00760982ea87d297d79b40ff246a0b1a3 /pbx
parent565a37f210bd5749b7fbe540a3ec3c427a6847af (diff)
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: http://svn.digium.com/svn/asterisk/trunk@1183 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'pbx')
-rwxr-xr-xpbx/pbx_config.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/pbx/pbx_config.c b/pbx/pbx_config.c
index 45953c6f5..0b15e5694 100755
--- a/pbx/pbx_config.c
+++ b/pbx/pbx_config.c
@@ -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;
}