]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
loader/main: Don't set ast_fully_booted until deferred reloads are processed
authorGeorge Joseph <george.joseph@fairview5.com>
Thu, 9 Apr 2015 22:31:58 +0000 (22:31 +0000)
committerGeorge Joseph <george.joseph@fairview5.com>
Thu, 9 Apr 2015 22:31:58 +0000 (22:31 +0000)
Until we have a true module management facility it's sometimes necessary for one
module to force a reload on another before its own load is complete.  If
Asterisk isn't fully booted yet, these reloads are deferred.  The problem is
that asterisk reports fully booted before processing the deferred reloads which
means Asterisk really isn't quite ready when it says it is.

This patch moves the report of fully booted after the processing of the deferred
reloads is complete.

Since the pjsip stack has the most number of related modules, I ran the
channels/pjsip testsuite to make sure there aren't any issues.  All tests
passed.

Tested-by: George Joseph
Review: https://reviewboard.asterisk.org/r/4604/

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@434544 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/asterisk.c
main/loader.c

index 082935d22b95369f08dc17ae5f3db8012ee9ab12..aa9d1f6b778e5f27b65021441581e3a42536acc6 100644 (file)
@@ -4671,11 +4671,11 @@ int main(int argc, char *argv[])
                sig_alert_pipe[0] = sig_alert_pipe[1] = -1;
        }
 
+       ast_process_pending_reloads();
+
        ast_set_flag(&ast_options, AST_OPT_FLAG_FULLY_BOOTED);
        publish_fully_booted();
 
-       ast_process_pending_reloads();
-
        pthread_sigmask(SIG_UNBLOCK, &sigs, NULL);
 
 #if defined(__AST_DEBUG_MALLOC)
index 3a596bcf4c45f49383832ffeb14ea626e6aed389..814bb976893b6b2f175b577654a01e77ae794bb8 100644 (file)
@@ -115,6 +115,11 @@ static unsigned int embedding = 1; /* we always start out by registering embedde
                                      since they are here before we dlopen() any
                                   */
 
+/*!
+ * \brief Internal flag to indicate all modules have been initially loaded.
+ */
+static int modules_loaded;
+
 struct ast_module {
        const struct ast_module_info *info;
 #ifdef REF_DEBUG
@@ -767,9 +772,7 @@ void ast_process_pending_reloads(void)
 {
        struct reload_queue_item *item;
 
-       if (!ast_fully_booted) {
-               return;
-       }
+       modules_loaded = 1;
 
        AST_LIST_LOCK(&reload_queue);
 
@@ -879,7 +882,7 @@ enum ast_module_reload_result ast_module_reload(const char *name)
 
        /* If we aren't fully booted, we just pretend we reloaded but we queue this
           up to run once we are booted up. */
-       if (!ast_fully_booted) {
+       if (!modules_loaded) {
                queue_reload_request(name);
                res = AST_MODULE_RELOAD_QUEUED;
                goto module_reload_exit;