diff options
author | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2010-07-23 16:44:53 +0000 |
---|---|---|
committer | tilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b> | 2010-07-23 16:44:53 +0000 |
commit | e69ee322da87401f9c451d580f1604f2148da0cc (patch) | |
tree | 7575b062e1c2a2ff2d8176556883360bf3689be0 /main/asterisk.c | |
parent | ba8829076df99adb91056ab54b43b9944865604c (diff) |
Merged revisions 278982 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
................
r278982 | tilghman | 2010-07-23 11:43:34 -0500 (Fri, 23 Jul 2010) | 15 lines
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: http://svn.digium.com/svn/asterisk/branches/1.6.2@278983 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/asterisk.c')
-rw-r--r-- | main/asterisk.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/main/asterisk.c b/main/asterisk.c index c51e8cc82..c8bed4a53 100644 --- a/main/asterisk.c +++ b/main/asterisk.c @@ -1626,14 +1626,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"); |