[asterisk-commits] tilghman: trunk r278982 - in /trunk: ./ main/asterisk.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jul 23 11:43:38 CDT 2010


Author: tilghman
Date: Fri Jul 23 11:43:34 2010
New Revision: 278982

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=278982
Log:
Merged revisions 278981 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
  r278981 | tilghman | 2010-07-23 11:42:25 -0500 (Fri, 23 Jul 2010) | 8 lines
  
  Avoid race with consolethread on shutdown (on parallel processors).
  
  (closes issue #17080)
   Reported by: sybasesql
   Patches: 
         20100721__issue17080.diff.txt uploaded by tilghman (license 14)
   Tested by: sybasesql
........

Modified:
    trunk/   (props changed)
    trunk/main/asterisk.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Modified: trunk/main/asterisk.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/asterisk.c?view=diff&rev=278982&r1=278981&r2=278982
==============================================================================
--- trunk/main/asterisk.c (original)
+++ trunk/main/asterisk.c Fri Jul 23 11:43:34 2010
@@ -1635,14 +1635,21 @@
 			ast_module_shutdown();
 	}
 	if (ast_opt_console || (ast_opt_remote && !ast_opt_exec)) {
-		if (getenv("HOME")) 
+		if (getenv("HOME")) {
 			snprintf(filename, sizeof(filename), "%s/.asterisk_history", getenv("HOME"));
-		if (!ast_strlen_zero(filename))
+		}
+		if (!ast_strlen_zero(filename)) {
 			ast_el_write_history(filename);
-		if (el != NULL)
-			el_end(el);
-		if (el_hist != NULL)
-			history_end(el_hist);
+		}
+		if (consolethread == AST_PTHREADT_NULL || consolethread == pthread_self()) {
+			/* Only end if we are the consolethread, otherwise there's a race with that thread. */
+			if (el != NULL) {
+				el_end(el);
+			}
+			if (el_hist != NULL) {
+				history_end(el_hist);
+			}
+		}
 	}
 	if (option_verbose)
 		ast_verbose("Executing last minute cleanups\n");




More information about the asterisk-commits mailing list