Index: logger.c =================================================================== --- logger.c (revision 48368) +++ logger.c (working copy) @@ -368,13 +368,19 @@ { va_list ap; ast_mutex_lock(&loglock); + int res; + if (qlog) { va_start(ap, fmt); - fprintf(qlog, "%ld|%s|%s|%s|%s|", (long)time(NULL), callid, queuename, agent, event); - vfprintf(qlog, fmt, ap); - fprintf(qlog, "\n"); + res = fprintf(qlog, "%ld|%s|%s|%s|%s|", (long)time(NULL), callid, queuename, agent, event); + if (res >= 0) res = vfprintf(qlog, fmt, ap); + if (res >= 0) res = fprintf(qlog, "\n"); + if (res >= 0) res = fflush(qlog); + if (res <= 0 && errno == EFBIG) + filesize_reload_needed = 1; + va_end(ap); - fflush(qlog); + } ast_mutex_unlock(&loglock); } @@ -593,20 +599,13 @@ handle_logger_rotate, "Rotates and reopens the log files", logger_rotate_help }; -static int handle_SIGXFSZ(int sig) -{ - /* Indicate need to reload */ - filesize_reload_needed = 1; - return 0; -} - int init_logger(void) { char tmp[256]; int res = 0; - /* auto rotate if sig SIGXFSZ comes a-knockin */ - (void) signal(SIGXFSZ,(void *) handle_SIGXFSZ); + if (sigignore(SIGXFSZ)) + ast_log(LOG_WARNING, "Failed to ignore SIGXFSZ\n"); /* register the relaod logger cli command */ ast_cli_register(&reload_logger_cli); @@ -697,7 +696,8 @@ time_t t; struct tm tm; char date[256]; - + int res; + va_list ap; if (!logchannels) @@ -743,10 +743,13 @@ if (logfiles.event_log && level == __LOG_EVENT) { va_start(ap, fmt); - fprintf(eventlog, "%s asterisk[%d]: ", date, getpid()); - vfprintf(eventlog, fmt, ap); - fflush(eventlog); - + res = fprintf(eventlog, "%s asterisk[%d]: ", date, getpid()); + if (res >= 0) res = vfprintf(eventlog, fmt, ap); + if (res >= 0) res = fflush(eventlog); + + if (res <= 0 && errno == EFBIG) + filesize_reload_needed = 1; + va_end(ap); ast_mutex_unlock(&loglock); return; @@ -788,6 +791,8 @@ res = fprintf(chan->fileptr, buf); if (res <= 0 && buf[0] != '\0') { /* Error, no characters printed */ fprintf(stderr,"**** Asterisk Logging Error: ***********\n"); + if (errno == EFBIG) + filesize_reload_needed = 1; if (errno == ENOMEM || errno == ENOSPC) { fprintf(stderr, "Asterisk logging error: Out of disk space, can't log to log file %s\n", chan->filename); } else