[asterisk-commits] file: branch file/moddepends r80034 - in /team/file/moddepends: include/aster...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Aug 20 10:14:42 CDT 2007
Author: file
Date: Mon Aug 20 10:14:41 2007
New Revision: 80034
URL: http://svn.digium.com/view/asterisk?view=rev&rev=80034
Log:
Add basic module dependency checking. When the module is loaded an array of other modules it depends on are checked to see if the previous ones are loaded and if not the module is not loaded.
Modified:
team/file/moddepends/include/asterisk/module.h
team/file/moddepends/main/loader.c
team/file/moddepends/pbx/pbx_ael.c
Modified: team/file/moddepends/include/asterisk/module.h
URL: http://svn.digium.com/view/asterisk/team/file/moddepends/include/asterisk/module.h?view=diff&rev=80034&r1=80033&r2=80034
==============================================================================
--- team/file/moddepends/include/asterisk/module.h (original)
+++ team/file/moddepends/include/asterisk/module.h Mon Aug 20 10:14:41 2007
@@ -192,6 +192,8 @@
AST_MODFLAG_GLOBAL_SYMBOLS = (1 << 0),
};
+#define MAX_DEPENDS 5
+
struct ast_module_info {
/*! The 'self' pointer for a module; it will be set by the loader before
@@ -207,6 +209,8 @@
void (*restore_globals)(void); /*!< for embedded modules, restore global data */
const char *name; /*!< name of the module for loader reference and CLI commands */
const char *description; /*!< user friendly description of the module. */
+
+ const char *depends[MAX_DEPENDS]; /*!< modules this module depends on */
/*!
* This holds the ASTERISK_GPL_KEY, signifiying that you agree to the terms of
Modified: team/file/moddepends/main/loader.c
URL: http://svn.digium.com/view/asterisk/team/file/moddepends/main/loader.c?view=diff&rev=80034&r1=80033&r2=80034
==============================================================================
--- team/file/moddepends/main/loader.c (original)
+++ team/file/moddepends/main/loader.c Mon Aug 20 10:14:41 2007
@@ -618,6 +618,7 @@
struct ast_module *mod;
enum ast_module_load_result res = AST_MODULE_LOAD_SUCCESS;
char tmp[256];
+ int i = 0;
if ((mod = find_resource(resource_name, 0))) {
if (mod->flags.running) {
@@ -654,6 +655,16 @@
if (!mod->lib && mod->info->backup_globals()) {
ast_log(LOG_WARNING, "Module '%s' was unable to backup its global data.\n", resource_name);
return AST_MODULE_LOAD_DECLINE;
+ }
+
+ for (i = 0; i < MAX_DEPENDS; i++) {
+ if (!mod->info->depends[i])
+ break;
+ /* Make sure the specified module has already been loaded */
+ if (!ast_module_check(mod->info->depends[i])) {
+ ast_log(LOG_WARNING, "Module '%s' requires '%s' which is not loaded.\n", resource_name, mod->info->depends[i]);
+ return AST_MODULE_LOAD_DECLINE;
+ }
}
mod->flags.declined = 0;
Modified: team/file/moddepends/pbx/pbx_ael.c
URL: http://svn.digium.com/view/asterisk/team/file/moddepends/pbx/pbx_ael.c?view=diff&rev=80034&r1=80033&r2=80034
==============================================================================
--- team/file/moddepends/pbx/pbx_ael.c (original)
+++ team/file/moddepends/pbx/pbx_ael.c Mon Aug 20 10:14:41 2007
@@ -1808,6 +1808,7 @@
.load = load_module,
.unload = unload_module,
.reload = reload,
+ .depends = {"res_ael_share", },
);
#ifdef AAL_ARGCHECK
More information about the asterisk-commits
mailing list