From 02287658f7ade7cead3928370a09f5c95f4be3b7 Mon Sep 17 00:00:00 2001 From: Mark Spencer Date: Wed, 14 Apr 2004 21:10:00 +0000 Subject: [PATCH] Store modules in the order they're loaded to make reload work properly git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@2691 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- loader.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/loader.c b/loader.c index f16ca45fc6..e6ff19fee5 100755 --- a/loader.c +++ b/loader.c @@ -305,9 +305,22 @@ int ast_load_resource(char *resource_name) if (option_verbose) ast_verbose(VERBOSE_PREFIX_1 "Loaded %s => (%s)\n", fn, m->description()); } - m->next = module_list; + + // add module 'm' to end of module_list chain + // so reload commands will be issued in same order modules were loaded + m->next = NULL; + if (module_list == NULL) { + // empty list so far, add at front + module_list = m; + } + else { + struct module *i; + // find end of chain, and add there + for (i = module_list; i->next; i = i->next) + ; + i->next = m; + } - module_list = m; ast_mutex_unlock(&modlock); if ((res = m->load_module())) { ast_log(LOG_WARNING, "%s: load_module failed, returning %d\n", m->resource, res);