From: Richard Mudgett Date: Tue, 11 Dec 2012 02:42:34 +0000 (+0000) Subject: Cleanup logger on exit. X-Git-Tag: 10.12.0-rc2~3^2~17 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c82c84be1fe20fa84b738ecd258788396222410e;p=thirdparty%2Fasterisk.git Cleanup logger on exit. * Cleanup CLI commands, destroy verbosers and logchannels lists on exit. (issue ASTERISK-20649) Reported by: Corey Farrell Patches: logger-cleanup-all.patch (license #5909) patch uploaded by Corey Farrell Modified ........ Merged revisions 377771 from http://svn.asterisk.org/svn/asterisk/branches/1.8 git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/10@377772 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/main/logger.c b/main/logger.c index 91102f040d..e46a81c1aa 100644 --- a/main/logger.c +++ b/main/logger.c @@ -1155,6 +1155,9 @@ int init_logger(void) void close_logger(void) { struct logchannel *f = NULL; + struct verb *cur = NULL; + + ast_cli_unregister_multiple(cli_logger, ARRAY_LEN(cli_logger)); logger_initialized = 0; @@ -1167,6 +1170,12 @@ void close_logger(void) if (logthread != AST_PTHREADT_NULL) pthread_join(logthread, NULL); + AST_RWLIST_WRLOCK(&verbosers); + while ((cur = AST_LIST_REMOVE_HEAD(&verbosers, list))) { + ast_free(cur); + } + AST_RWLIST_UNLOCK(&verbosers); + AST_RWLIST_WRLOCK(&logchannels); if (qlog) { @@ -1174,11 +1183,12 @@ void close_logger(void) qlog = NULL; } - AST_RWLIST_TRAVERSE(&logchannels, f, list) { + while ((f = AST_LIST_REMOVE_HEAD(&logchannels, list))) { if (f->fileptr && (f->fileptr != stdout) && (f->fileptr != stderr)) { fclose(f->fileptr); f->fileptr = NULL; } + ast_free(f); } closelog(); /* syslog */