[asterisk-commits] rmudgett: branch 11 r377706 - in /branches/11: ./ main/dnsmgr.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Dec 10 18:34:49 CST 2012
Author: rmudgett
Date: Mon Dec 10 18:34:46 2012
New Revision: 377706
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=377706
Log:
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
Modified:
branches/11/ (props changed)
branches/11/main/dnsmgr.c
Propchange: branches/11/
------------------------------------------------------------------------------
Binary property 'branch-10-merged' - no diff available.
Modified: branches/11/main/dnsmgr.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/dnsmgr.c?view=diff&rev=377706&r1=377705&r2=377706
==============================================================================
--- branches/11/main/dnsmgr.c (original)
+++ branches/11/main/dnsmgr.c Mon Dec 10 18:34:46 2012
@@ -397,6 +397,26 @@
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())) {
@@ -406,6 +426,9 @@
ast_cli_register(&cli_reload);
ast_cli_register(&cli_status);
ast_cli_register(&cli_refresh);
+
+ ast_register_atexit(dnsmgr_shutdown);
+
return do_reload(1);
}
More information about the asterisk-commits
mailing list