[Asterisk-code-review] pbx config.c: Fix reloading module if initially declined to ... (asterisk[16])
Joshua Colp
asteriskteam at digium.com
Tue Sep 4 06:36:11 CDT 2018
Joshua Colp has submitted this change and it was merged. ( https://gerrit.asterisk.org/9886 )
Change subject: pbx_config.c: Fix reloading module if initially declined to load
......................................................................
pbx_config.c: Fix reloading module if initially declined to load
Added decline if extensions.conf file not available
when loading pbx_config, and also made sure everything
gets properly unregistered and/or destroyed on unload.
Change-Id: Ib00665106043b1be5148ffa7a477396038915854
---
M pbx/pbx_config.c
1 file changed, 18 insertions(+), 9 deletions(-)
Approvals:
Richard Mudgett: Looks good to me, but someone else must approve
Joshua Colp: Looks good to me, approved; Approved for Submit
diff --git a/pbx/pbx_config.c b/pbx/pbx_config.c
index 9577d2d..b1d5d53 100644
--- a/pbx/pbx_config.c
+++ b/pbx/pbx_config.c
@@ -1625,15 +1625,15 @@
*/
static int unload_module(void)
{
- if (static_config && !write_protect_config)
- ast_cli_unregister(&cli_dialplan_save);
- if (overrideswitch_config) {
- ast_free(overrideswitch_config);
- }
+ ast_cli_unregister(&cli_dialplan_save);
+ ast_free(overrideswitch_config);
+ overrideswitch_config = NULL;
+
ast_cli_unregister_multiple(cli_pbx_config, ARRAY_LEN(cli_pbx_config));
ast_manager_unregister(AMI_EXTENSION_ADD);
ast_manager_unregister(AMI_EXTENSION_REMOVE);
ast_context_destroy(NULL, registrar);
+
return 0;
}
@@ -2081,10 +2081,17 @@
ast_mutex_lock(&reload_lock);
- if (!local_table)
+ if (!local_table) {
local_table = ast_hashtab_create(17, ast_hashtab_compare_contexts, ast_hashtab_resize_java, ast_hashtab_newsize_java, ast_hashtab_hash_contexts, 0);
+ if (!local_table) {
+ ast_mutex_unlock(&reload_lock);
+ return AST_MODULE_LOAD_DECLINE;
+ }
+ }
if (!pbx_load_config(config)) {
+ ast_hashtab_destroy(local_table, NULL);
+ local_table = NULL;
ast_mutex_unlock(&reload_lock);
return AST_MODULE_LOAD_DECLINE;
}
@@ -2111,6 +2118,11 @@
{
int res;
+ if (pbx_load_module()) {
+ unload_module();
+ return AST_MODULE_LOAD_DECLINE;
+ }
+
if (static_config && !write_protect_config)
ast_cli_register(&cli_dialplan_save);
ast_cli_register_multiple(cli_pbx_config, ARRAY_LEN(cli_pbx_config));
@@ -2125,9 +2137,6 @@
return AST_MODULE_LOAD_DECLINE;
}
- if (pbx_load_module())
- return AST_MODULE_LOAD_DECLINE;
-
return AST_MODULE_LOAD_SUCCESS;
}
--
To view, visit https://gerrit.asterisk.org/9886
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib00665106043b1be5148ffa7a477396038915854
Gerrit-Change-Number: 9886
Gerrit-PatchSet: 4
Gerrit-Owner: Chris Savinovich <csavinovich at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180904/c813fd83/attachment-0001.html>
More information about the asterisk-code-review
mailing list