diff --git a/include/asterisk/_private.h b/include/asterisk/_private.h index a7ed68136f3212ae6b155f88c1c3df611dc1cc05..1bc24337f0415858504178cf2d84857617307277 100644 --- a/include/asterisk/_private.h +++ b/include/asterisk/_private.h @@ -19,6 +19,7 @@ int load_modules(unsigned int); /*!< Provided by loader.c */ int load_pbx(void); /*!< Provided by pbx.c */ int init_logger(void); /*!< Provided by logger.c */ void close_logger(void); /*!< Provided by logger.c */ +void logger_queue_start(void); /*!< Provided by logger.c */ void clean_time_zones(void); /*!< Provided by localtime.c */ int init_framer(void); /*!< Provided by frame.c */ int ast_term_init(void); /*!< Provided by term.c */ diff --git a/main/asterisk.c b/main/asterisk.c index 660fe2af536beced8744341a9783800fe59e6400..2fecf242e14e7578d84d071dac2fb529f3308fda 100644 --- a/main/asterisk.c +++ b/main/asterisk.c @@ -4380,6 +4380,8 @@ int main(int argc, char *argv[]) run_startup_commands(); + logger_queue_start(); + if (ast_opt_console) { /* Console stuff now... */ /* Register our quit function */ diff --git a/main/logger.c b/main/logger.c index e0e012e52f1f7ac008810c7a6d85cb1ac942c9e9..323f1c6e6306bbcdac8ec33973f9e6efc4a7864e 100644 --- a/main/logger.c +++ b/main/logger.c @@ -235,8 +235,6 @@ AST_THREADSTORAGE(verbose_buf); AST_THREADSTORAGE(log_buf); #define LOG_BUF_INIT_SIZE 256 -static void logger_queue_init(void); - static void make_components(struct logchannel *chan) { char *w; @@ -548,20 +546,8 @@ void ast_queue_log(const char *queuename, const char *callid, const char *agent, return; } if (!queuelog_init) { - AST_RWLIST_WRLOCK(&logchannels); - if (!queuelog_init) { - /* - * We have delayed initializing the queue logging system so - * preloaded realtime modules can get up. We must initialize - * now since someone is trying to log something. - */ - logger_queue_init(); - queuelog_init = 1; - AST_RWLIST_UNLOCK(&logchannels); - ast_queue_log("NONE", "NONE", "NONE", "QUEUESTART", "%s", ""); - } else { - AST_RWLIST_UNLOCK(&logchannels); - } + /* We must initialize now since someone is trying to log something. */ + logger_queue_start(); } if (ast_check_realtime("queue_log")) { @@ -1265,6 +1251,30 @@ static void logger_queue_init(void) } } +/*! + * \brief Start the ast_queue_log() logger. + * + * \note Called when the system is fully booted after startup + * so preloaded realtime modules can get up. + * + * \return Nothing + */ +void logger_queue_start(void) +{ + /* Must not be called before the logger is initialized. */ + ast_assert(logger_initialized); + + AST_RWLIST_WRLOCK(&logchannels); + if (!queuelog_init) { + logger_queue_init(); + queuelog_init = 1; + AST_RWLIST_UNLOCK(&logchannels); + ast_queue_log("NONE", "NONE", "NONE", "QUEUESTART", "%s", ""); + } else { + AST_RWLIST_UNLOCK(&logchannels); + } +} + int init_logger(void) { /* auto rotate if sig SIGXFSZ comes a-knockin */