[asterisk-commits] russell: branch 1.6.0 r233841 - in /branches/1.6.0: ./ formats/ include/aster...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Dec 9 09:29:04 CST 2009
Author: russell
Date: Wed Dec 9 09:28:59 2009
New Revision: 233841
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=233841
Log:
Set a module load priority for format modules.
A recent change to app_voicemail made it such that the module now assumes that
all format modules are available while processing voicemail configuration.
However, when autoloading modules, it was possible that app_voicemail was
loaded before the format modules. Since format modules don't depend on
anything, set a module load priority on them to ensure that they get loaded
first when autoloading.
This version of the patch is specific to Asterisk 1.4 and 1.6.0. These versions
did not already support module load priority in the module API. This adds a
trivial version of this which is just a module flag to include it in a pass before
loading "everything".
Thanks to mmichelson for the review!
(closes issue #16412)
Reported by: jiddings
Tested by: russell
Review: https://reviewboard.asterisk.org/r/445/
Modified:
branches/1.6.0/UPGRADE-1.6.txt (props changed)
branches/1.6.0/UPGRADE.txt (props changed)
branches/1.6.0/formats/format_g723.c
branches/1.6.0/formats/format_g726.c
branches/1.6.0/formats/format_g729.c
branches/1.6.0/formats/format_gsm.c
branches/1.6.0/formats/format_h263.c
branches/1.6.0/formats/format_h264.c
branches/1.6.0/formats/format_ilbc.c
branches/1.6.0/formats/format_jpeg.c
branches/1.6.0/formats/format_ogg_vorbis.c
branches/1.6.0/formats/format_pcm.c
branches/1.6.0/formats/format_sln.c
branches/1.6.0/formats/format_sln16.c
branches/1.6.0/formats/format_vox.c
branches/1.6.0/formats/format_wav.c
branches/1.6.0/formats/format_wav_gsm.c
branches/1.6.0/include/asterisk/module.h
branches/1.6.0/main/editline/makelist.in (props changed)
branches/1.6.0/main/loader.c
Propchange: branches/1.6.0/UPGRADE-1.6.txt
('svn:mergeinfo' removed)
Propchange: branches/1.6.0/UPGRADE.txt
('svn:mergeinfo' removed)
Modified: branches/1.6.0/formats/format_g723.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.0/formats/format_g723.c?view=diff&rev=233841&r1=233840&r2=233841
==============================================================================
--- branches/1.6.0/formats/format_g723.c (original)
+++ branches/1.6.0/formats/format_g723.c Wed Dec 9 09:28:59 2009
@@ -149,4 +149,7 @@
return ast_format_unregister(g723_1_f.name);
}
-AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "G.723.1 Simple Timestamp File Format");
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_FIRST, "G.723.1 Simple Timestamp File Format",
+ .load = load_module,
+ .unload = unload_module,
+);
Modified: branches/1.6.0/formats/format_g726.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.0/formats/format_g726.c?view=diff&rev=233841&r1=233840&r2=233841
==============================================================================
--- branches/1.6.0/formats/format_g726.c (original)
+++ branches/1.6.0/formats/format_g726.c Wed Dec 9 09:28:59 2009
@@ -258,4 +258,7 @@
return(0);
}
-AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Raw G.726 (16/24/32/40kbps) data");
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_FIRST, "Raw G.726 (16/24/32/40kbps) data",
+ .load = load_module,
+ .unload = unload_module,
+);
Modified: branches/1.6.0/formats/format_g729.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.0/formats/format_g729.c?view=diff&rev=233841&r1=233840&r2=233841
==============================================================================
--- branches/1.6.0/formats/format_g729.c (original)
+++ branches/1.6.0/formats/format_g729.c Wed Dec 9 09:28:59 2009
@@ -145,4 +145,7 @@
return ast_format_unregister(g729_f.name);
}
-AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Raw G729 data");
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_FIRST, "Raw G729 data",
+ .load = load_module,
+ .unload = unload_module,
+);
Modified: branches/1.6.0/formats/format_gsm.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.0/formats/format_gsm.c?view=diff&rev=233841&r1=233840&r2=233841
==============================================================================
--- branches/1.6.0/formats/format_gsm.c (original)
+++ branches/1.6.0/formats/format_gsm.c Wed Dec 9 09:28:59 2009
@@ -169,4 +169,7 @@
return ast_format_unregister(gsm_f.name);
}
-AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Raw GSM data");
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_FIRST, "Raw GSM data",
+ .load = load_module,
+ .unload = unload_module,
+);
Modified: branches/1.6.0/formats/format_h263.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.0/formats/format_h263.c?view=diff&rev=233841&r1=233840&r2=233841
==============================================================================
--- branches/1.6.0/formats/format_h263.c (original)
+++ branches/1.6.0/formats/format_h263.c Wed Dec 9 09:28:59 2009
@@ -183,4 +183,7 @@
return ast_format_unregister(h263_f.name);
}
-AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Raw H.263 data");
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_FIRST, "Raw H.263 data",
+ .load = load_module,
+ .unload = unload_module,
+);
Modified: branches/1.6.0/formats/format_h264.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.0/formats/format_h264.c?view=diff&rev=233841&r1=233840&r2=233841
==============================================================================
--- branches/1.6.0/formats/format_h264.c (original)
+++ branches/1.6.0/formats/format_h264.c Wed Dec 9 09:28:59 2009
@@ -172,4 +172,7 @@
return ast_format_unregister(h264_f.name);
}
-AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Raw H.264 data");
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_FIRST, "Raw H.264 data",
+ .load = load_module,
+ .unload = unload_module,
+);
Modified: branches/1.6.0/formats/format_ilbc.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.0/formats/format_ilbc.c?view=diff&rev=233841&r1=233840&r2=233841
==============================================================================
--- branches/1.6.0/formats/format_ilbc.c (original)
+++ branches/1.6.0/formats/format_ilbc.c Wed Dec 9 09:28:59 2009
@@ -143,4 +143,7 @@
return ast_format_unregister(ilbc_f.name);
}
-AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Raw iLBC data");
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_FIRST, "Raw iLBC data",
+ .load = load_module,
+ .unload = unload_module,
+);
Modified: branches/1.6.0/formats/format_jpeg.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.0/formats/format_jpeg.c?view=diff&rev=233841&r1=233840&r2=233841
==============================================================================
--- branches/1.6.0/formats/format_jpeg.c (original)
+++ branches/1.6.0/formats/format_jpeg.c Wed Dec 9 09:28:59 2009
@@ -112,4 +112,7 @@
return 0;
}
-AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "JPEG (Joint Picture Experts Group) Image Format");
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_FIRST, "JPEG (Joint Picture Experts Group) Image Format",
+ .load = load_module,
+ .unload = unload_module,
+);
Modified: branches/1.6.0/formats/format_ogg_vorbis.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.0/formats/format_ogg_vorbis.c?view=diff&rev=233841&r1=233840&r2=233841
==============================================================================
--- branches/1.6.0/formats/format_ogg_vorbis.c (original)
+++ branches/1.6.0/formats/format_ogg_vorbis.c Wed Dec 9 09:28:59 2009
@@ -556,5 +556,8 @@
return ast_format_unregister(vorbis_f.name);
}
-AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "OGG/Vorbis audio");
-
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_FIRST, "OGG/Vorbis audio",
+ .load = load_module,
+ .unload = unload_module,
+);
+
Modified: branches/1.6.0/formats/format_pcm.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.0/formats/format_pcm.c?view=diff&rev=233841&r1=233840&r2=233841
==============================================================================
--- branches/1.6.0/formats/format_pcm.c (original)
+++ branches/1.6.0/formats/format_pcm.c Wed Dec 9 09:28:59 2009
@@ -494,4 +494,7 @@
|| ast_format_unregister(g722_f.name);
}
-AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Raw/Sun uLaw/ALaw 8KHz (PCM,PCMA,AU), G.722 16Khz");
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_FIRST, "Raw/Sun uLaw/ALaw 8KHz (PCM,PCMA,AU), G.722 16Khz",
+ .load = load_module,
+ .unload = unload_module,
+);
Modified: branches/1.6.0/formats/format_sln.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.0/formats/format_sln.c?view=diff&rev=233841&r1=233840&r2=233841
==============================================================================
--- branches/1.6.0/formats/format_sln.c (original)
+++ branches/1.6.0/formats/format_sln.c Wed Dec 9 09:28:59 2009
@@ -127,4 +127,7 @@
return ast_format_unregister(slin_f.name);
}
-AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Raw Signed Linear Audio support (SLN)");
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_FIRST, "Raw Signed Linear Audio support (SLN)",
+ .load = load_module,
+ .unload = unload_module,
+);
Modified: branches/1.6.0/formats/format_sln16.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.0/formats/format_sln16.c?view=diff&rev=233841&r1=233840&r2=233841
==============================================================================
--- branches/1.6.0/formats/format_sln16.c (original)
+++ branches/1.6.0/formats/format_sln16.c Wed Dec 9 09:28:59 2009
@@ -135,4 +135,7 @@
return ast_format_unregister(slin_f.name);
}
-AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Raw Signed Linear 16KHz Audio support (SLN16)");
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_FIRST, "Raw Signed Linear 16KHz Audio support (SLN16)",
+ .load = load_module,
+ .unload = unload_module,
+);
Modified: branches/1.6.0/formats/format_vox.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.0/formats/format_vox.c?view=diff&rev=233841&r1=233840&r2=233841
==============================================================================
--- branches/1.6.0/formats/format_vox.c (original)
+++ branches/1.6.0/formats/format_vox.c Wed Dec 9 09:28:59 2009
@@ -132,4 +132,7 @@
return ast_format_unregister(vox_f.name);
}
-AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Dialogic VOX (ADPCM) File Format");
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_FIRST, "Dialogic VOX (ADPCM) File Format",
+ .load = load_module,
+ .unload = unload_module,
+);
Modified: branches/1.6.0/formats/format_wav.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.0/formats/format_wav.c?view=diff&rev=233841&r1=233840&r2=233841
==============================================================================
--- branches/1.6.0/formats/format_wav.c (original)
+++ branches/1.6.0/formats/format_wav.c Wed Dec 9 09:28:59 2009
@@ -491,4 +491,7 @@
return ast_format_unregister(wav_f.name);
}
-AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Microsoft WAV format (8000Hz Signed Linear)");
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_FIRST, "Microsoft WAV format (8000Hz Signed Linear)",
+ .load = load_module,
+ .unload = unload_module,
+);
Modified: branches/1.6.0/formats/format_wav_gsm.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.0/formats/format_wav_gsm.c?view=diff&rev=233841&r1=233840&r2=233841
==============================================================================
--- branches/1.6.0/formats/format_wav_gsm.c (original)
+++ branches/1.6.0/formats/format_wav_gsm.c Wed Dec 9 09:28:59 2009
@@ -548,4 +548,7 @@
return ast_format_unregister(wav49_f.name);
}
-AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Microsoft WAV format (Proprietary GSM)");
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_FIRST, "Microsoft WAV format (Proprietary GSM)",
+ .load = load_module,
+ .unload = unload_module,
+);
Modified: branches/1.6.0/include/asterisk/module.h
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.0/include/asterisk/module.h?view=diff&rev=233841&r1=233840&r2=233841
==============================================================================
--- branches/1.6.0/include/asterisk/module.h (original)
+++ branches/1.6.0/include/asterisk/module.h Wed Dec 9 09:28:59 2009
@@ -189,6 +189,14 @@
enum ast_module_flags {
AST_MODFLAG_DEFAULT = 0,
AST_MODFLAG_GLOBAL_SYMBOLS = (1 << 0),
+ /*!
+ * \brief Load this module in the first pass on auto loading
+ *
+ * When module auto loading is used, modules with this flag set will
+ * be loaded after preloaded modules, but before all modules being
+ * automatically loaded without this flag set on them.
+ */
+ AST_MODFLAG_LOAD_FIRST = (1 << 2),
};
struct ast_module_info {
Propchange: branches/1.6.0/main/editline/makelist.in
('svn:mergeinfo' removed)
Modified: branches/1.6.0/main/loader.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.0/main/loader.c?view=diff&rev=233841&r1=233840&r2=233841
==============================================================================
--- branches/1.6.0/main/loader.c (original)
+++ branches/1.6.0/main/loader.c Wed Dec 9 09:28:59 2009
@@ -124,6 +124,19 @@
is being registered
*/
struct ast_module *resource_being_loaded;
+
+/*! \brief Load modules in this order. */
+enum module_load_pass {
+ /*! \brief AST_MODFLAG_LOAD_FIRST */
+ LOAD_FIRST,
+ /*! \brief AST_MODFLAG_GLOBAL_SYMBOLS */
+ LOAD_GLOBAL_SYMBOLS,
+ /*! \brief everything that is left */
+ LOAD_ALL,
+
+ /*! \brief Must remain at the end. */
+ LOAD_DONE,
+};
/* XXX: should we check for duplicate resource names here? */
@@ -348,12 +361,12 @@
while (!dlclose(lib));
}
-static struct ast_module *load_dynamic_module(const char *resource_in, unsigned int global_symbols_only)
+static struct ast_module *load_dynamic_module(const char *resource_in, enum module_load_pass load_pass)
{
char fn[PATH_MAX] = "";
void *lib = NULL;
struct ast_module *mod;
- unsigned int wants_global;
+ unsigned int wants_global = 0, not_yet = 0;
int space; /* room needed for the descriptor */
int missing_so = 0;
@@ -398,11 +411,22 @@
return NULL;
}
- wants_global = ast_test_flag(mod->info, AST_MODFLAG_GLOBAL_SYMBOLS);
-
- /* if we are being asked only to load modules that provide global symbols,
- and this one does not, then close it and return */
- if (global_symbols_only && !wants_global) {
+ switch (load_pass) {
+ case LOAD_FIRST:
+ not_yet = !ast_test_flag(mod->info, AST_MODFLAG_LOAD_FIRST);
+ break;
+ case LOAD_GLOBAL_SYMBOLS:
+ wants_global = ast_test_flag(mod->info, AST_MODFLAG_GLOBAL_SYMBOLS);
+ not_yet = !wants_global;
+ break;
+ case LOAD_ALL:
+ break;
+ case LOAD_DONE:
+ ast_log(LOG_ERROR, "Satan just bought a snowblower! (This should never happen, btw.)\n");
+ break;
+ }
+
+ if (not_yet) {
while (!dlclose(lib));
return NULL;
}
@@ -709,7 +733,7 @@
return 0;
}
-static enum ast_module_load_result load_resource(const char *resource_name, unsigned int global_symbols_only)
+static enum ast_module_load_result load_resource(const char *resource_name, enum module_load_pass load_pass)
{
struct ast_module *mod;
enum ast_module_load_result res = AST_MODULE_LOAD_SUCCESS;
@@ -720,13 +744,29 @@
ast_log(LOG_WARNING, "Module '%s' already exists.\n", resource_name);
return AST_MODULE_LOAD_DECLINE;
}
- if (global_symbols_only && !ast_test_flag(mod->info, AST_MODFLAG_GLOBAL_SYMBOLS))
- return AST_MODULE_LOAD_SKIP;
+
+ switch (load_pass) {
+ case LOAD_FIRST:
+ if (!ast_test_flag(mod->info, AST_MODFLAG_LOAD_FIRST)) {
+ return AST_MODULE_LOAD_SKIP;
+ }
+ break;
+ case LOAD_GLOBAL_SYMBOLS:
+ if (!ast_test_flag(mod->info, AST_MODFLAG_GLOBAL_SYMBOLS)) {
+ return AST_MODULE_LOAD_SKIP;
+ }
+ break;
+ case LOAD_ALL:
+ break;
+ case LOAD_DONE:
+ ast_log(LOG_ERROR, "This should never happen, -EFLAMES!\n");
+ break;
+ }
} else {
#ifdef LOADABLE_MODULES
- if (!(mod = load_dynamic_module(resource_name, global_symbols_only))) {
+ if (!(mod = load_dynamic_module(resource_name, load_pass))) {
/* don't generate a warning message during load_modules() */
- if (!global_symbols_only) {
+ if (load_pass == LOAD_ALL) {
ast_log(LOG_WARNING, "Module '%s' could not be loaded.\n", resource_name);
return AST_MODULE_LOAD_DECLINE;
} else {
@@ -830,6 +870,7 @@
int res = 0;
struct ast_flags config_flags = { 0 };
int modulecount = 0;
+ int load_pass;
#ifdef LOADABLE_MODULES
struct dirent *dirent;
@@ -936,45 +977,29 @@
if (load_count)
ast_log(LOG_NOTICE, "%d modules will be loaded.\n", load_count);
- /* first, load only modules that provide global symbols */
- AST_LIST_TRAVERSE_SAFE_BEGIN(&load_order, order, entry) {
- switch (load_resource(order->resource, 1)) {
- case AST_MODULE_LOAD_SUCCESS:
- modulecount++;
- case AST_MODULE_LOAD_DECLINE:
- AST_LIST_REMOVE_CURRENT(entry);
- ast_free(order->resource);
- ast_free(order);
- break;
- case AST_MODULE_LOAD_FAILURE:
- res = -1;
- goto done;
- case AST_MODULE_LOAD_SKIP:
- /* try again later */
- break;
- }
- }
- AST_LIST_TRAVERSE_SAFE_END;
-
- /* now load everything else */
- AST_LIST_TRAVERSE_SAFE_BEGIN(&load_order, order, entry) {
- switch (load_resource(order->resource, 0)) {
- case AST_MODULE_LOAD_SUCCESS:
- modulecount++;
- case AST_MODULE_LOAD_DECLINE:
- AST_LIST_REMOVE_CURRENT(entry);
- ast_free(order->resource);
- ast_free(order);
- break;
- case AST_MODULE_LOAD_FAILURE:
- res = -1;
- goto done;
- case AST_MODULE_LOAD_SKIP:
- /* should not happen */
- break;
- }
- }
- AST_LIST_TRAVERSE_SAFE_END;
+ for (load_pass = 0; load_pass < LOAD_DONE; load_pass++) {
+ AST_LIST_TRAVERSE_SAFE_BEGIN(&load_order, order, entry) {
+ switch (load_resource(order->resource, load_pass)) {
+ case AST_MODULE_LOAD_SUCCESS:
+ modulecount++;
+ case AST_MODULE_LOAD_DECLINE:
+ AST_LIST_REMOVE_CURRENT(entry);
+ ast_free(order->resource);
+ ast_free(order);
+ break;
+ case AST_MODULE_LOAD_FAILURE:
+ res = -1;
+ goto done;
+ case AST_MODULE_LOAD_SKIP:
+ /*
+ * Try again later. This result is received when a module is
+ * deferred because it is not a part of the current pass.
+ */
+ break;
+ }
+ }
+ AST_LIST_TRAVERSE_SAFE_END;
+ }
done:
while ((order = AST_LIST_REMOVE_HEAD(&load_order, entry))) {
More information about the asterisk-commits
mailing list