diff options
author | Richard Mudgett <rmudgett@digium.com> | 2012-12-11 00:37:01 +0000 |
---|---|---|
committer | Richard Mudgett <rmudgett@digium.com> | 2012-12-11 00:37:01 +0000 |
commit | f7954f54db2576e9602f0d9b352b51035ba48821 (patch) | |
tree | f2d4197d398ca824054b35145fff4ec78d4950d6 /main/dnsmgr.c | |
parent | 34cbefe62fc9851a03aaa3ace803b6c21b68fc25 (diff) |
Cleanup dnsmgr on exit.
* Cleanup dnsmgr thread and CLI commands on exit.
(issue ASTERISK-20649)
Reported by: Corey Farrell
Patches:
dnsmgr-cleanup-1_8.patch (license #5909) patch uploaded by Corey Farrell
dnsmgr-cleanup-10-11-trunk.patch (license #5909) patch uploaded by Corey Farrell
Modified
........
Merged revisions 377704 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........
Merged revisions 377705 from http://svn.asterisk.org/svn/asterisk/branches/10
........
Merged revisions 377706 from http://svn.asterisk.org/svn/asterisk/branches/11
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@377707 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/dnsmgr.c')
-rw-r--r-- | main/dnsmgr.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/main/dnsmgr.c b/main/dnsmgr.c index 1a5fd154e..bfba4714d 100644 --- a/main/dnsmgr.c +++ b/main/dnsmgr.c @@ -408,6 +408,26 @@ static struct ast_cli_entry cli_reload = AST_CLI_DEFINE(handle_cli_reload, "Relo static struct ast_cli_entry cli_refresh = AST_CLI_DEFINE(handle_cli_refresh, "Performs an immediate refresh"); static struct ast_cli_entry cli_status = AST_CLI_DEFINE(handle_cli_status, "Display the DNS manager status"); +static void dnsmgr_shutdown(void) +{ + ast_cli_unregister(&cli_reload); + ast_cli_unregister(&cli_status); + ast_cli_unregister(&cli_refresh); + + /* Destroy refresh thread. */ + ast_mutex_lock(&refresh_lock); + if (refresh_thread != AST_PTHREADT_NULL) { + /* wake up the thread so it will exit */ + pthread_cancel(refresh_thread); + pthread_kill(refresh_thread, SIGURG); + pthread_join(refresh_thread, NULL); + refresh_thread = AST_PTHREADT_NULL; + } + ast_mutex_unlock(&refresh_lock); + + ast_sched_context_destroy(sched); +} + int dnsmgr_init(void) { if (!(sched = ast_sched_context_create())) { @@ -417,6 +437,9 @@ int dnsmgr_init(void) ast_cli_register(&cli_reload); ast_cli_register(&cli_status); ast_cli_register(&cli_refresh); + + ast_register_atexit(dnsmgr_shutdown); + return do_reload(1); } |