]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Unregister CLI commands on exit
authorKinsey Moore <kmoore@digium.com>
Tue, 20 Aug 2013 15:27:16 +0000 (15:27 +0000)
committerKinsey Moore <kmoore@digium.com>
Tue, 20 Aug 2013 15:27:16 +0000 (15:27 +0000)
This patch ensures that CLI commands enabled by DEBUG_FD_LEAKS and
DEBUG_THREADLOCALS are cleaned up properly on exit.

(closes issue ASTERISK-22238)
Reported by: Corey Farrell
Tested by: Corey Farrell
Patches:
    debug_cli_unregister.patch uploaded by Corey Farrell
........

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

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

main/astfd.c
main/threadstorage.c

index 79094840d60022fa0337af8d23c3a655ee3275d9..b2dfd12ee61a17b46ddbfc8e795989451391687c 100644 (file)
@@ -274,8 +274,14 @@ static char *handle_show_fd(struct ast_cli_entry *e, int cmd, struct ast_cli_arg
 
 static struct ast_cli_entry cli_show_fd = AST_CLI_DEFINE(handle_show_fd, "Show open file descriptors");
 
+static void fd_shutdown(void)
+{
+       ast_cli_unregister(&cli_show_fd);
+}
+
 int ast_fd_init(void)
 {
+       ast_register_atexit(fd_shutdown);
        return ast_cli_register(&cli_show_fd);
 }
 
index c89d1078d07da05f3361419646a4dd1cfaf96fd5..349cb4ecdf7cbd2a4509eb93177f7c780d4ec36e 100644 (file)
@@ -249,10 +249,16 @@ static struct ast_cli_entry cli[] = {
        AST_CLI_DEFINE(handle_cli_threadstorage_show_summary,     "Summarize outstanding memory allocations")
 };
 
+static void threadstorage_shutdown(void)
+{
+       ast_cli_unregister_multiple(cli, ARRAY_LEN(cli));
+}
+
 void threadstorage_init(void)
 {
        pthread_mutex_init(&threadstoragelock, NULL);
        ast_cli_register_multiple(cli, ARRAY_LEN(cli));
+       ast_register_atexit(threadstorage_shutdown);
 }
 
 #endif /* !defined(DEBUG_THREADLOCALS) */