[asterisk-commits] rmudgett: branch 10 r360934 - in /branches/10: ./ main/logger.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Mar 30 16:29:54 CDT 2012


Author: rmudgett
Date: Fri Mar 30 16:29:43 2012
New Revision: 360934

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=360934
Log:
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

Modified:
    branches/10/   (props changed)
    branches/10/main/logger.c

Propchange: branches/10/
------------------------------------------------------------------------------
Binary property 'branch-1.8-merged' - no diff available.

Modified: branches/10/main/logger.c
URL: http://svnview.digium.com/svn/asterisk/branches/10/main/logger.c?view=diff&rev=360934&r1=360933&r2=360934
==============================================================================
--- branches/10/main/logger.c (original)
+++ branches/10/main/logger.c Fri Mar 30 16:29:43 2012
@@ -1053,6 +1053,7 @@
 		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);
@@ -1170,8 +1171,6 @@
 	closelog(); /* syslog */
 
 	AST_RWLIST_UNLOCK(&logchannels);
-
-	return;
 }
 
 /*!
@@ -1258,15 +1257,18 @@
 	/* 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);
 		ast_free(logmsg);
 	}
-
-	return;
 }
 
 #ifdef HAVE_BKTR




More information about the asterisk-commits mailing list