[Asterisk-code-review] pbx config.c: (asterisk[13])

Chris Savinovich asteriskteam at digium.com
Wed Aug 15 14:44:58 CDT 2018


Chris Savinovich has uploaded this change for review. ( https://gerrit.asterisk.org/9883


Change subject: pbx_config.c:
......................................................................

pbx_config.c:

Added exit if conf file not available
on load_module, and also made sure
everything gets unregistered on unload.

Change-Id: Ib00665106043b1be5148ffa7a477396038915854
---
M pbx/pbx_config.c
1 file changed, 13 insertions(+), 5 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/83/9883/1

diff --git a/pbx/pbx_config.c b/pbx/pbx_config.c
index 65daa2a..a1518aa 100644
--- a/pbx/pbx_config.c
+++ b/pbx/pbx_config.c
@@ -1599,15 +1599,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;
 }
 
@@ -2074,6 +2074,14 @@
 static int load_module(void)
 {
 	int res;
+    struct ast_config *cfg;
+    struct ast_flags config_flags = { 0 };
+
+    cfg = ast_config_load(config, config_flags);
+    if (!cfg || cfg == CONFIG_STATUS_FILEINVALID) {
+        unload_module();
+        return AST_MODULE_LOAD_DECLINE;
+    }
 
 	if (static_config && !write_protect_config)
 		ast_cli_register(&cli_dialplan_save);

-- 
To view, visit https://gerrit.asterisk.org/9883
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib00665106043b1be5148ffa7a477396038915854
Gerrit-Change-Number: 9883
Gerrit-PatchSet: 1
Gerrit-Owner: Chris Savinovich <csavinovich at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180815/29c6551d/attachment.html>


More information about the asterisk-code-review mailing list