[asterisk-commits] rmudgett: trunk r377809 - in /trunk: ./ main/pbx.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Dec 11 14:05:36 CST 2012


Author: rmudgett
Date: Tue Dec 11 14:05:32 2012
New Revision: 377809

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=377809
Log:
Cleanup pbx on exit.

* Cleanup CLI commands on exit.

* Unreference hints and statecbs containers on exit.

(issue ASTERISK-20649)
Reported by: Corey Farrell
Patches:
      pbx-cleanup-1_8.patch (license #5909) patch uploaded by Corey Farrell
      pbx-cleanup-10.patch (license #5909) patch uploaded by Corey Farrell
      pbx-cleanup-11-trunk.patch (license #5909) patch uploaded by Corey Farrell
      Modified
........

Merged revisions 377806 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 377807 from http://svn.asterisk.org/svn/asterisk/branches/10
........

Merged revisions 377808 from http://svn.asterisk.org/svn/asterisk/branches/11

Modified:
    trunk/   (props changed)
    trunk/main/pbx.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-11-merged' - no diff available.

Modified: trunk/main/pbx.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/pbx.c?view=diff&rev=377809&r1=377808&r2=377809
==============================================================================
--- trunk/main/pbx.c (original)
+++ trunk/main/pbx.c Tue Dec 11 14:05:32 2012
@@ -11747,6 +11747,7 @@
 		ast_unregister_application(builtins[x].name);
 	}
 	ast_manager_unregister("ShowDialPlan");
+	ast_cli_unregister_multiple(pbx_cli, ARRAY_LEN(pbx_cli));
 	ast_custom_function_unregister(&exception_function);
 	ast_custom_function_unregister(&testtime_function);
 	ast_data_unregister(NULL);
@@ -11758,6 +11759,8 @@
 int load_pbx(void)
 {
 	int x;
+
+	ast_register_atexit(unload_pbx);
 
 	/* Initialize the PBX */
 	ast_verb(1, "Asterisk PBX Core Initializing\n");
@@ -11793,7 +11796,6 @@
 		return -1;
 	}
 
-	ast_register_atexit(unload_pbx);
 	return 0;
 }
 
@@ -12154,17 +12156,23 @@
 	return (state_cb->change_cb == change_cb) ? CMP_MATCH | CMP_STOP : 0;
 }
 
-/*! \internal \brief Clean up resources on Asterisk shutdown */
+/*!
+ * \internal
+ * \brief Clean up resources on Asterisk shutdown
+ */
 static void pbx_shutdown(void)
 {
 	if (hints) {
 		ao2_ref(hints, -1);
+		hints = NULL;
 	}
 	if (hintdevices) {
 		ao2_ref(hintdevices, -1);
+		hintdevices = NULL;
 	}
 	if (statecbs) {
 		ao2_ref(statecbs, -1);
+		statecbs = NULL;
 	}
 }
 
@@ -12175,5 +12183,6 @@
 	statecbs = ao2_container_alloc(1, NULL, statecbs_cmp);
 
 	ast_register_atexit(pbx_shutdown);
+
 	return (hints && hintdevices && statecbs) ? 0 : -1;
 }




More information about the asterisk-commits mailing list