summaryrefslogtreecommitdiff
path: root/res/res_calendar.c
diff options
context:
space:
mode:
authorMatthew Jordan <mjordan@digium.com>2014-07-25 14:27:52 +0000
committerMatthew Jordan <mjordan@digium.com>2014-07-25 14:27:52 +0000
commitba9867fab07b4e6f74916c898122bb6705598413 (patch)
tree32cae9ab0355a659fbb0a1d71e7fad994084078d /res/res_calendar.c
parent41042588b9a2ed15a1be910fb23bdb60f03e1a9b (diff)
module loader: Unload modules in reverse order of their start order
When Asterisk starts a module (calling its load_module function), it re-orders the module list, sorting it alphabetically. Ostensibly, this was done so that the output of 'module show' listed modules in alphabetic order. This had the unfortunate side effect of making modules with complex usage patterns unloadable. A module that has a large number of modules that depend on it is typically abandoned during the unloading process. This results in its memory not being reclaimed during exit. Generally, this isn't harmful - when the process is destroyed, the operating system will reclaim all memory allocated by the process. Prior to Asterisk 12, we also didn't have many modules with complex dependencies. However, with the advent of ARI and PJSIP, this can make make unloading those modules successfully nearly impossible, and thus tracking memory leaks or ref debug leaks a real pain. While this patch is not a complete overhaul of the module loader - such an effort would be beyond the scope of what could be done for Asterisk 13 - this does make some marginal improvements to the loader such that modules like res_pjsip or res_stasis *may* be made properly un-loadable in the future. 1. The linked list of modules has been replaced with a doubly linked list. This allows traversal of the module list to occur backwards. The module shutdown routine now walks the global list backwards when it attempts to unload modules. 2. The alphabetic reorganization of the module list on startup has been removed. Instead, a started module is placed at the end of the module list. 3. The ast_update_module_list function - which is used by the CLI to display the modules - now does the sorting alphabetically itself. It creates its own linked list and inserts the modules into it in alphabetic order. This allows for the intent of the previous code to be maintained. This patch also contains a fix for res_calendar. Without calendar.conf, the calendar modules were improperly bumping the use count of res_calendar, then failing to load themselves. This patch makes it so that we detect whether or not calendaring is enabled before altering the use count. Review: https://reviewboard.asterisk.org/r/3777/ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@419563 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/res_calendar.c')
-rw-r--r--res/res_calendar.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/res/res_calendar.c b/res/res_calendar.c
index 77f8ef662..34c94f64a 100644
--- a/res/res_calendar.c
+++ b/res/res_calendar.c
@@ -538,6 +538,11 @@ int ast_calendar_register(struct ast_calendar_tech *tech)
{
struct ast_calendar_tech *iter;
+ if (!calendar_config) {
+ ast_log(LOG_WARNING, "Calendar support disabled, not loading %s calendar module\n", tech->type);
+ return -1;
+ }
+
AST_LIST_LOCK(&techs);
AST_LIST_TRAVERSE(&techs, iter, list) {
if(!strcasecmp(tech->type, iter->type)) {