[Asterisk-code-review] loader: Process dependencies for built-in modules. (asterisk[16])

Joshua Colp asteriskteam at digium.com
Fri Jul 27 06:04:34 CDT 2018


Joshua Colp has submitted this change and it was merged. ( https://gerrit.asterisk.org/9717 )

Change subject: loader: Process dependencies for built-in modules.
......................................................................

loader: Process dependencies for built-in modules.

With the new module loader it was missed that built-in modules never
parsed dependencies from mod->info into vectors of mod.  This caused
manager to be initialized before acl (named_acl).  If manager.conf
used any named ACL's they would not be found and result in no ACL being
applied to the AMI user.

In addition to the manager ACL fix this adds "extconfig" to all builtin
modules which support realtime configuration.  This only matters if one
of the builtin modules is configured with 'preload', depending on
"extconfig" will cause config.c to automatically be initialize during
the preload stage.

Change-Id: I482ed6bca6c1064b05bb538d7861cd7a4f02d9fc
---
M main/cdr.c
M main/cel.c
M main/dnsmgr.c
M main/dsp.c
M main/enum.c
M main/features.c
M main/http.c
M main/indications.c
M main/loader.c
M main/logger.c
M main/manager.c
M main/named_acl.c
M main/plc.c
M main/sounds.c
M main/udptl.c
15 files changed, 32 insertions(+), 6 deletions(-)

Approvals:
  Kevin Harwell: Looks good to me, but someone else must approve
  Richard Mudgett: Looks good to me, but someone else must approve
  Joshua Colp: Looks good to me, approved; Approved for Submit



diff --git a/main/cdr.c b/main/cdr.c
index 62fcdf5..1c47e24 100644
--- a/main/cdr.c
+++ b/main/cdr.c
@@ -4628,4 +4628,5 @@
 	.unload = unload_module,
 	.reload = reload_module,
 	.load_pri = AST_MODPRI_CORE,
+	.requires = "extconfig",
 );
diff --git a/main/cel.c b/main/cel.c
index 91c625a..0ec728e 100644
--- a/main/cel.c
+++ b/main/cel.c
@@ -1753,4 +1753,5 @@
 	.unload = unload_module,
 	.reload = reload_module,
 	.load_pri = AST_MODPRI_CORE,
+	.requires = "extconfig",
 );
diff --git a/main/dnsmgr.c b/main/dnsmgr.c
index c25b601..db13b1d 100644
--- a/main/dnsmgr.c
+++ b/main/dnsmgr.c
@@ -523,4 +523,5 @@
 	.unload = unload_module,
 	.reload = reload_module,
 	.load_pri = AST_MODPRI_CORE,
+	.requires = "extconfig",
 );
diff --git a/main/dsp.c b/main/dsp.c
index ea653d8..433e61a 100644
--- a/main/dsp.c
+++ b/main/dsp.c
@@ -2425,4 +2425,5 @@
 	.unload = unload_module,
 	.reload = reload_module,
 	.load_pri = AST_MODPRI_CORE,
+	.requires = "extconfig",
 );
diff --git a/main/enum.c b/main/enum.c
index 8b6d3fe..344ae40 100644
--- a/main/enum.c
+++ b/main/enum.c
@@ -1023,4 +1023,5 @@
 	.unload = unload_module,
 	.reload = reload_module,
 	.load_pri = AST_MODPRI_CORE,
+	.requires = "extconfig",
 );
diff --git a/main/features.c b/main/features.c
index 3db6d39..8c2d9bc 100644
--- a/main/features.c
+++ b/main/features.c
@@ -1174,4 +1174,5 @@
 	.unload = unload_module,
 	.reload = reload_features_config,
 	.load_pri = AST_MODPRI_CORE,
+	.requires = "extconfig",
 );
diff --git a/main/http.c b/main/http.c
index 55d1029..d7ec60a 100644
--- a/main/http.c
+++ b/main/http.c
@@ -2314,4 +2314,5 @@
 	.unload = unload_module,
 	.reload = reload_module,
 	.load_pri = AST_MODPRI_CORE,
+	.requires = "extconfig",
 );
diff --git a/main/indications.c b/main/indications.c
index c9f0241..6a7414d 100644
--- a/main/indications.c
+++ b/main/indications.c
@@ -1158,4 +1158,5 @@
 	.unload = unload_module,
 	.reload = reload_module,
 	.load_pri = AST_MODPRI_CORE,
+	.requires = "extconfig",
 );
diff --git a/main/loader.c b/main/loader.c
index d6837f8..eb345b5 100644
--- a/main/loader.c
+++ b/main/loader.c
@@ -569,6 +569,18 @@
 	*((struct ast_module **) &(info->self)) = mod;
 }
 
+static int module_post_register(struct ast_module *mod)
+{
+	int res;
+
+	/* Split lists from mod->info. */
+	res  = ast_vector_string_split(&mod->requires, mod->info->requires, ",", 0, strcasecmp);
+	res |= ast_vector_string_split(&mod->optional_modules, mod->info->optional_modules, ",", 0, strcasecmp);
+	res |= ast_vector_string_split(&mod->enhances, mod->info->enhances, ",", 0, strcasecmp);
+
+	return res;
+}
+
 static void module_destroy(struct ast_module *mod)
 {
 	AST_VECTOR_CALLBACK_VOID(&mod->requires, ast_free);
@@ -1526,11 +1538,7 @@
 			return required ? AST_MODULE_LOAD_FAILURE : AST_MODULE_LOAD_DECLINE;
 		}
 
-		/* Split lists from mod->info. */
-		res  = ast_vector_string_split(&mod->requires, mod->info->requires, ",", 0, strcasecmp);
-		res |= ast_vector_string_split(&mod->optional_modules, mod->info->optional_modules, ",", 0, strcasecmp);
-		res |= ast_vector_string_split(&mod->enhances, mod->info->enhances, ",", 0, strcasecmp);
-		if (res) {
+		if (module_post_register(mod)) {
 			goto prestart_error;
 		}
 	}
@@ -1846,6 +1854,11 @@
 			continue;
 		}
 
+		/* Parse dependendencies from mod->info. */
+		if (module_post_register(mod)) {
+			return -1;
+		}
+
 		/* Built-in modules are not preloaded, most have an early load priority. */
 		if (!add_to_load_order(mod->resource, load_order, 0, 0, 1)) {
 			return -1;
diff --git a/main/logger.c b/main/logger.c
index 46d61ed..8b4f678 100644
--- a/main/logger.c
+++ b/main/logger.c
@@ -2381,6 +2381,7 @@
 	.support_level = AST_MODULE_SUPPORT_CORE,
 	.load = load_module,
 	.unload = unload_module,
+	/* This reload does not support realtime so it does not require "extconfig". */
 	.reload = reload_module,
 	.load_pri = 0,
 );
diff --git a/main/manager.c b/main/manager.c
index ab42432..a0dcf6c 100644
--- a/main/manager.c
+++ b/main/manager.c
@@ -9600,5 +9600,5 @@
 	.unload = unload_module,
 	.reload = reload_module,
 	.load_pri = AST_MODPRI_CORE,
-	.requires = "http",
+	.requires = "extconfig,acl,http",
 );
diff --git a/main/named_acl.c b/main/named_acl.c
index c462821..8cf09c2 100644
--- a/main/named_acl.c
+++ b/main/named_acl.c
@@ -591,4 +591,5 @@
 	.unload = unload_module,
 	.reload = reload_module,
 	.load_pri = AST_MODPRI_CORE,
+	.requires = "extconfig",
 );
diff --git a/main/plc.c b/main/plc.c
index 369d285..20d5122 100644
--- a/main/plc.c
+++ b/main/plc.c
@@ -296,4 +296,5 @@
 	.unload = unload_module,
 	.reload = reload_module,
 	.load_pri = AST_MODPRI_CORE,
+	.requires = "extconfig",
 );
diff --git a/main/sounds.c b/main/sounds.c
index 745b628..e0cb33a 100644
--- a/main/sounds.c
+++ b/main/sounds.c
@@ -340,6 +340,7 @@
 	.support_level = AST_MODULE_SUPPORT_CORE,
 	.load = load_module,
 	.unload = unload_module,
+	/* This reload doesn't use config so this module doesn't require "extconfig". */
 	.reload = reload_module,
 	/* Load after the format modules to reduce processing during startup. */
 	.load_pri = AST_MODPRI_APP_DEPEND + 1,
diff --git a/main/udptl.c b/main/udptl.c
index f6cd3b9..7349d6a 100644
--- a/main/udptl.c
+++ b/main/udptl.c
@@ -1420,4 +1420,5 @@
 	.unload = unload_module,
 	.reload = reload_module,
 	.load_pri = AST_MODPRI_CORE,
+	.requires = "extconfig",
 );

-- 
To view, visit https://gerrit.asterisk.org/9717
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: I482ed6bca6c1064b05bb538d7861cd7a4f02d9fc
Gerrit-Change-Number: 9717
Gerrit-PatchSet: 3
Gerrit-Owner: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell 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/20180727/ef986a4d/attachment-0001.html>


More information about the asterisk-code-review mailing list