]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Process outstanding log messages before shutting down the logger thread.
authorJoshua Colp <jcolp@digium.com>
Wed, 10 Oct 2007 13:46:57 +0000 (13:46 +0000)
committerJoshua Colp <jcolp@digium.com>
Wed, 10 Oct 2007 13:46:57 +0000 (13:46 +0000)
(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

index a74cfa31e8f102bcd5de5caade9e6067b6ecfdc1..fae61d45409d367ddce6c5f9e5cf5b842197f1cb 100644 (file)
@@ -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) {