aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjpeeler <jpeeler@f38db490-d61c-443f-a65b-d21fe96a405b>2010-10-08 03:00:40 +0000
committerjpeeler <jpeeler@f38db490-d61c-443f-a65b-d21fe96a405b>2010-10-08 03:00:40 +0000
commitbccb73bf04041afbc4d4b7026ab6e9b3bc1f2f16 (patch)
treec0a11a7c0e04ec4ec9b9c00d6e22c1b1ff6f0316
parent6940b2504aca22d0b499cb6c4e5e0065e428bf3c (diff)
Merged revisions 290864 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8 ................ r290864 | jpeeler | 2010-10-07 21:56:24 -0500 (Thu, 07 Oct 2010) | 23 lines Merged revisions 290863 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.6.2 ................ r290863 | jpeeler | 2010-10-07 21:45:44 -0500 (Thu, 07 Oct 2010) | 16 lines Merged revisions 290862 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r290862 | jpeeler | 2010-10-07 21:35:29 -0500 (Thu, 07 Oct 2010) | 9 lines Ensure editline cleanup occurs when Ctrl-C is pressed at control console. A recent change was made to avoid a race condition on shutdown which only called the end functions from the console thread. However, when pressing Ctrl-C the quit handler is called from the signal handler thread. (closes issue #17698) Reported by: jmls ........ ................ ................ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@290865 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--main/asterisk.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/main/asterisk.c b/main/asterisk.c
index 364bdf7e3..ca3f68ba9 100644
--- a/main/asterisk.c
+++ b/main/asterisk.c
@@ -278,6 +278,7 @@ static char *_argv[256];
static int shuttingdown;
static int restartnow;
static pthread_t consolethread = AST_PTHREADT_NULL;
+static pthread_t mon_sig_flags;
static int canary_pid = 0;
static char canary_filename[128];
@@ -1637,14 +1638,15 @@ 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)) {
+ pthread_t thisthread = pthread_self();
if (getenv("HOME")) {
snprintf(filename, sizeof(filename), "%s/.asterisk_history", getenv("HOME"));
}
if (!ast_strlen_zero(filename)) {
ast_el_write_history(filename);
}
- if (consolethread == AST_PTHREADT_NULL || consolethread == pthread_self()) {
- /* Only end if we are the consolethread, otherwise there's a race with that thread. */
+ if (consolethread == AST_PTHREADT_NULL || consolethread == thisthread || mon_sig_flags == thisthread) {
+ /* Only end if we are the consolethread or signal handler, otherwise there's a race with that thread. */
if (el != NULL) {
el_end(el);
}
@@ -3835,9 +3837,8 @@ int main(int argc, char *argv[])
/* Console stuff now... */
/* Register our quit function */
char title[256];
- pthread_t dont_care;
- ast_pthread_create_detached(&dont_care, NULL, monitor_sig_flags, NULL);
+ ast_pthread_create_detached(&mon_sig_flags, NULL, monitor_sig_flags, NULL);
set_icon("Asterisk");
snprintf(title, sizeof(title), "Asterisk Console on '%s' (pid %ld)", hostname, (long)ast_mainpid);