summaryrefslogtreecommitdiff
path: root/main/asterisk.c
diff options
context:
space:
mode:
authorTilghman Lesher <tilghman@meg.abyt.es>2010-07-23 16:43:34 +0000
committerTilghman Lesher <tilghman@meg.abyt.es>2010-07-23 16:43:34 +0000
commitec482eac9c53fab4346878611cb0c041b5695fa4 (patch)
tree3fd44377fa9d6daa6b98d01c91386b3377d8f3b4 /main/asterisk.c
parentd1ad460b3d02322a7cacb0b1f35ed86a78973344 (diff)
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 ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@278982 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/asterisk.c')
-rw-r--r--main/asterisk.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/main/asterisk.c b/main/asterisk.c
index e82223d58..d8d3aebdf 100644
--- a/main/asterisk.c
+++ b/main/asterisk.c
@@ -1635,14 +1635,21 @@ static void quit_handler(int num, int niceness, int safeshutdown, int restart)
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");