]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Cleanup taskprocessor on exit.
authorRichard Mudgett <rmudgett@digium.com>
Tue, 11 Dec 2012 20:42:59 +0000 (20:42 +0000)
committerRichard Mudgett <rmudgett@digium.com>
Tue, 11 Dec 2012 20:42:59 +0000 (20:42 +0000)
* Cleanup CLI commands on exit.

* v10 only: Merged v1.8 -r374177 change to taskprocessor.c missed in v10 -r374178.

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

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

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/10@377838 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/taskprocessor.c

index a5e106b2802f0aa9a59ef92fce7ac27ca38ce039..c637ba24fdc6f3fd8c3d483900f2da721a619757 100644 (file)
@@ -122,6 +122,17 @@ static struct ast_cli_entry taskprocessor_clis[] = {
        AST_CLI_DEFINE(cli_tps_report, "List instantiated task processors and statistics"),
 };
 
+/*!
+ * \internal
+ * \brief Clean up resources on Asterisk shutdown
+ */
+static void tps_shutdown(void)
+{
+       ast_cli_unregister_multiple(taskprocessor_clis, ARRAY_LEN(taskprocessor_clis));
+       ao2_t_ref(tps_singletons, -1, "Unref tps_singletons in shutdown");
+       tps_singletons = NULL;
+}
+
 /* initialize the taskprocessor container and register CLI operations */
 int ast_tps_init(void)
 {
@@ -133,6 +144,9 @@ int ast_tps_init(void)
        ast_cond_init(&cli_ping_cond, NULL);
 
        ast_cli_register_multiple(taskprocessor_clis, ARRAY_LEN(taskprocessor_clis));
+
+       ast_register_atexit(tps_shutdown);
+
        return 0;
 }