aboutsummaryrefslogtreecommitdiffstats
path: root/main/logger.c
diff options
context:
space:
mode:
authormmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2009-02-16 18:38:00 +0000
committermmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2009-02-16 18:38:00 +0000
commit9d4ed10ca0c45a861474e68a493b1544fa1a1355 (patch)
treec53682fab340db86cb31a67c6ba000230dc6795a /main/logger.c
parent0dd3b773203ef402f8e15d2eaf502ab3df5af3b3 (diff)
Merged revisions 176174 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk ........ r176174 | mmichelson | 2009-02-16 12:25:57 -0600 (Mon, 16 Feb 2009) | 11 lines Assist proper thread synchronization when stopping the logger thread. I was finding that on my dev box, occasionally attempting to "stop now" in trunk would cause Asterisk to hang. I traced this to the fact that the logger thread was waiting on a condition which had already been signalled. The logger thread also need to be sure to check the value of the close_logger_thread variable. The close_logger_thread variable is only checked when the list of logmessages is empty. This allows for the logger thread to print and free any pending messages before exiting. ........ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.1@176176 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/logger.c')
-rw-r--r--main/logger.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/main/logger.c b/main/logger.c
index 07c346732..25cdfd1ed 100644
--- a/main/logger.c
+++ b/main/logger.c
@@ -969,8 +969,13 @@ static void *logger_thread(void *data)
for (;;) {
/* We lock the message list, and see if any message exists... if not we wait on the condition to be signalled */
AST_LIST_LOCK(&logmsgs);
- if (AST_LIST_EMPTY(&logmsgs))
- ast_cond_wait(&logcond, &logmsgs.lock);
+ if (AST_LIST_EMPTY(&logmsgs)) {
+ if (close_logger_thread) {
+ break;
+ } else {
+ ast_cond_wait(&logcond, &logmsgs.lock);
+ }
+ }
next = AST_LIST_FIRST(&logmsgs);
AST_LIST_HEAD_INIT_NOLOCK(&logmsgs);
AST_LIST_UNLOCK(&logmsgs);