From d19257304ef37b7737fdd7e409a11897e3547f7b Mon Sep 17 00:00:00 2001 From: Joshua Colp Date: Wed, 10 Oct 2007 13:46:57 +0000 Subject: [PATCH] Process outstanding log messages before shutting down the logger thread. (closes issue #10933) Reported by: sperreault git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@85234 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- main/logger.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/main/logger.c b/main/logger.c index a74cfa31e8..fae61d4540 100644 --- a/main/logger.c +++ b/main/logger.c @@ -859,10 +859,6 @@ static void *logger_thread(void *data) AST_LIST_HEAD_INIT_NOLOCK(&logmsgs); AST_LIST_UNLOCK(&logmsgs); - /* If we should stop, then stop */ - if (close_logger_thread) - break; - /* Otherwise go through and process each message in the order added */ while ((msg = next)) { /* Get the next entry now so that we can free our current structure later */ @@ -877,6 +873,10 @@ static void *logger_thread(void *data) /* Free the data since we are done */ free(msg); } + + /* If we should stop, then stop */ + if (close_logger_thread) + break; } return NULL; @@ -937,6 +937,9 @@ void close_logger(void) ast_cond_signal(&logcond); AST_LIST_UNLOCK(&logmsgs); + if (logthread != AST_PTHREADT_NULL) + pthread_join(logthread, NULL); + AST_RWLIST_WRLOCK(&logchannels); if (eventlog) {