Various fixes for when ngen is 0.

This commit is contained in:
lukem 2003-10-13 07:28:52 +00:00
parent ca9f17c96d
commit d048430db6
1 changed files with 17 additions and 14 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: newsyslog.c,v 1.46 2002/11/30 03:10:56 lukem Exp $ */
/* $NetBSD: newsyslog.c,v 1.47 2003/10/13 07:28:52 lukem Exp $ */
/*
* Copyright (c) 1999, 2000 Andrew Doran <ad@NetBSD.org>
@ -55,7 +55,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: newsyslog.c,v 1.46 2002/11/30 03:10:56 lukem Exp $");
__RCSID("$NetBSD: newsyslog.c,v 1.47 2003/10/13 07:28:52 lukem Exp $");
#endif /* not lint */
#include <sys/types.h>
@ -501,20 +501,22 @@ log_trim(struct conf_entry *log)
struct stat st;
pid_t pid;
/* Remove oldest historical log. */
snprintf(file1, sizeof(file1), "%s.%d", log->logfile,
log->numhist - 1);
if (log->numhist != 0) {
/* Remove oldest historical log. */
snprintf(file1, sizeof(file1), "%s.%d", log->logfile,
log->numhist - 1);
PRINFO(("rm -f %s\n", file1));
if (!noaction)
unlink(file1);
strlcat(file1, ".gz", sizeof(file1));
PRINFO(("rm -f %s\n", file1));
if (!noaction)
unlink(file1);
PRINFO(("rm -f %s\n", file1));
if (!noaction)
unlink(file1);
strlcat(file1, ".gz", sizeof(file1));
PRINFO(("rm -f %s\n", file1));
if (!noaction)
unlink(file1);
}
/* Move down log files. */
for (i = log->numhist - 1; i != 0; i--) {
for (i = log->numhist - 1; i > 0; i--) {
snprintf(file1, sizeof(file1), "%s.%d", log->logfile, i - 1);
snprintf(file2, sizeof(file2), "%s.%d", log->logfile, i);
@ -601,7 +603,8 @@ log_trim(struct conf_entry *log)
}
/* If the newest historical log is to be compressed, do it here. */
if ((log->flags & (CE_PLAIN0 | CE_COMPRESS)) == CE_COMPRESS) {
if ((log->flags & (CE_PLAIN0 | CE_COMPRESS)) == CE_COMPRESS
&& log->numhist != 0) {
snprintf(file1, sizeof(file1), "%s.0", log->logfile);
if ((log->flags & CE_NOSIGNAL) == 0) {
PRINFO(("sleep for 10 seconds before compressing...\n"));