[asterisk-commits] mmichelson: trunk r176174 - /trunk/main/logger.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Feb 16 12:25:57 CST 2009


Author: mmichelson
Date: Mon Feb 16 12:25:57 2009
New Revision: 176174

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


Modified:
    trunk/main/logger.c

Modified: trunk/main/logger.c
URL: http://svn.digium.com/svn-view/asterisk/trunk/main/logger.c?view=diff&rev=176174&r1=176173&r2=176174
==============================================================================
--- trunk/main/logger.c (original)
+++ trunk/main/logger.c Mon Feb 16 12:25:57 2009
@@ -973,8 +973,13 @@
 	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);




More information about the asterisk-commits mailing list