mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-19 03:08:45 +00:00
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 ........ Merged revisions 377772 from http://svn.asterisk.org/svn/asterisk/branches/10 ........ Merged revisions 377773 from http://svn.asterisk.org/svn/asterisk/branches/11 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@377774 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -1257,6 +1257,9 @@ int init_logger(void)
|
|||||||
void close_logger(void)
|
void close_logger(void)
|
||||||
{
|
{
|
||||||
struct logchannel *f = NULL;
|
struct logchannel *f = NULL;
|
||||||
|
struct verb *cur = NULL;
|
||||||
|
|
||||||
|
ast_cli_unregister_multiple(cli_logger, ARRAY_LEN(cli_logger));
|
||||||
|
|
||||||
logger_initialized = 0;
|
logger_initialized = 0;
|
||||||
|
|
||||||
@@ -1269,6 +1272,12 @@ void close_logger(void)
|
|||||||
if (logthread != AST_PTHREADT_NULL)
|
if (logthread != AST_PTHREADT_NULL)
|
||||||
pthread_join(logthread, 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);
|
AST_RWLIST_WRLOCK(&logchannels);
|
||||||
|
|
||||||
if (qlog) {
|
if (qlog) {
|
||||||
@@ -1276,11 +1285,12 @@ void close_logger(void)
|
|||||||
qlog = NULL;
|
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)) {
|
if (f->fileptr && (f->fileptr != stdout) && (f->fileptr != stderr)) {
|
||||||
fclose(f->fileptr);
|
fclose(f->fileptr);
|
||||||
f->fileptr = NULL;
|
f->fileptr = NULL;
|
||||||
}
|
}
|
||||||
|
ast_free(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
closelog(); /* syslog */
|
closelog(); /* syslog */
|
||||||
|
Reference in New Issue
Block a user