From: Valery Yatsko Date: Sun, 20 Apr 2008 03:42:30 +0000 (+0400) Subject: Splitted open_logfiles(); into open_logfiles(); and close_logfiles();, use the second... X-Git-Url: https://jfr.im/git/solanum.git/commitdiff_plain/ea82a3ca27cd11df8280d1c5d0d5c9f1bbd7e716 Splitted open_logfiles(); into open_logfiles(); and close_logfiles();, use the second one on ircd_shutdown --- diff --git a/include/logger.h b/include/logger.h index ee6ca3a9..6efa0ca4 100644 --- a/include/logger.h +++ b/include/logger.h @@ -55,6 +55,7 @@ struct Client; extern void init_main_logfile(void); extern void open_logfiles(void); +extern void close_logfiles(void); extern void ilog(ilogfile dest, const char *fmt, ...) AFP(2, 3); extern void inotice(const char *fmt, ...) AFP(1, 2); extern void iwarn(const char *fmt, ...) AFP(1, 2); diff --git a/src/ircd.c b/src/ircd.c index af922db1..7094d077 100644 --- a/src/ircd.c +++ b/src/ircd.c @@ -164,6 +164,7 @@ ircd_shutdown(const char *reason) } ilog(L_MAIN, "Server Terminating. %s", reason); + close_logfiles(); unlink(pidFileName); exit(0); diff --git a/src/logger.c b/src/logger.c index 3fea75b5..2246f25a 100644 --- a/src/logger.c +++ b/src/logger.c @@ -86,26 +86,37 @@ open_logfiles(void) { int i; - if(log_main != NULL) - fclose(log_main); + close_logfiles(); log_main = fopen(logFileName, "a"); /* log_main is handled above, so just do the rest */ for(i = 1; i < LAST_LOGFILE; i++) { - /* close open logfiles */ + /* reopen those with paths */ + if(!EmptyString(*log_table[i].name)) + *log_table[i].logfile = fopen(*log_table[i].name, "a"); + } +} + +void +close_logfiles(void) +{ + int i; + + if(log_main != NULL) + fclose(log_main); + + /* log_main is handled above, so just do the rest */ + for(i = 1; i < LAST_LOGFILE; i++) + { if(*log_table[i].logfile != NULL) { fclose(*log_table[i].logfile); *log_table[i].logfile = NULL; } - - /* reopen those with paths */ - if(!EmptyString(*log_table[i].name)) - *log_table[i].logfile = fopen(*log_table[i].name, "a"); } -} +} void ilog(ilogfile dest, const char *format, ...)