summaryrefslogtreecommitdiff
path: root/main/logger.c
diff options
context:
space:
mode:
authorRichard Mudgett <rmudgett@digium.com>2012-03-30 21:38:16 +0000
committerRichard Mudgett <rmudgett@digium.com>2012-03-30 21:38:16 +0000
commit6a540e908774d2c942f1c20ac2dd7c66b3f09cf0 (patch)
tree225fa5fa38124fc9c1a48c7c3c01e12382d08d45 /main/logger.c
parent314d4593174a561ab2ae761ff17262098a54ee9d (diff)
Fix logger deadlock on Asterisk shutdown.
The logger_thread() had an exit path that failed to release the logmsgs list lock. * Make logger_thread() exit path unlock the logmsgs list lock. * Made ast_log() not queue any messages to the logmsgs list if the close_logger_thread flag is set. (issue ASTERISK-19463) Reported by: Matt Jordan ........ Merged revisions 360933 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 360934 from http://svn.asterisk.org/svn/asterisk/branches/10 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@360935 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/logger.c')
-rw-r--r--main/logger.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/main/logger.c b/main/logger.c
index 5891e8709..fdab40d30 100644
--- a/main/logger.c
+++ b/main/logger.c
@@ -1116,6 +1116,7 @@ static void *logger_thread(void *data)
AST_LIST_LOCK(&logmsgs);
if (AST_LIST_EMPTY(&logmsgs)) {
if (close_logger_thread) {
+ AST_LIST_UNLOCK(&logmsgs);
break;
} else {
ast_cond_wait(&logcond, &logmsgs.lock);
@@ -1233,8 +1234,6 @@ void close_logger(void)
closelog(); /* syslog */
AST_RWLIST_UNLOCK(&logchannels);
-
- return;
}
struct ast_callid *ast_create_callid(void)
@@ -1379,15 +1378,18 @@ static void __attribute__((format(printf, 6, 0))) ast_log_full(int level, const
/* If the logger thread is active, append it to the tail end of the list - otherwise skip that step */
if (logthread != AST_PTHREADT_NULL) {
AST_LIST_LOCK(&logmsgs);
- AST_LIST_INSERT_TAIL(&logmsgs, logmsg, list);
- ast_cond_signal(&logcond);
+ if (close_logger_thread) {
+ /* Logger is either closing or closed. We cannot log this message. */
+ ast_free(logmsg);
+ } else {
+ AST_LIST_INSERT_TAIL(&logmsgs, logmsg, list);
+ ast_cond_signal(&logcond);
+ }
AST_LIST_UNLOCK(&logmsgs);
} else {
logger_print_normal(logmsg);
logmsg_free(logmsg);
}
-
- return;
}
void ast_log(int level, const char *file, int line, const char *function, const char *fmt, ...)