From: Joshua Colp Date: Wed, 10 Oct 2007 13:46:57 +0000 (+0000) Subject: Process outstanding log messages before shutting down the logger thread. X-Git-Tag: 1.6.0-beta1~3^2~1240 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d19257304ef37b7737fdd7e409a11897e3547f7b;p=thirdparty%2Fasterisk.git 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 --- 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) {