Date: Sat, 3 Sep 2011 11:40:31 -0600 (MDT) From: Ian Lepore <freebsd@damnhippie.dyndns.org> To: FreeBSD-gnats-submit@FreeBSD.org Subject: kern/160432: [patch] Allow both size and at-time specifications for log rotation. Message-ID: <201109031740.p83HeVWS098843@revolution.hippie.lan> Resent-Message-ID: <201109031750.p83Ho984003775@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 160432
>Category: kern
>Synopsis: [patch] Allow both size and at-time specifications for log rotation.
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Sat Sep 03 17:50:08 UTC 2011
>Closed-Date:
>Last-Modified:
>Originator: Ian Lepore <freebsd@damnhippie.dyndns.org>
>Release: FreeBSD 8.2-RC3 arm
>Organization:
none
>Environment:
FreeBSD dvb 8.2-RC3 FreeBSD 8.2-RC3 #49: Tue Feb 15 22:52:14 UTC 2011 root@revolution.hippie.lan:/usr/obj/arm/usr/src/sys/DVB arm
>Description:
If both size-based and time-based rotation parameters are specified for the
same log file in newsyslog.conf, the size specification is effectively
ignored because the rotation-decision logic returns early if the at-time
test isn't satisfied.
>How-To-Repeat:
Specify both a size limit and a time specification for the same file. The
log will not be rotated until the designated time regardless of how large
it becomes before then.
>Fix:
This patch allows both size and time to be specified in a useful way. The
log file will be rotated when either the size is exceeded or the designated
time arrives.
--- diff.tmp begins here ---
--- newsyslog.c.orig 2011-09-03 11:26:46.000000000 -0600
+++ newsyslog.c 2011-08-31 16:06:09.000000000 -0600
@@ -516,7 +516,12 @@ do_entry(struct conf_entry * ent)
printf("does not exist, skipped%s.\n", temp_reason);
}
} else {
- if (ent->flags & CE_TRIMAT && !force && !rotatereq) {
+ if (ent->trsize > 0 && ent->fsize >= ent->trsize) {
+ if (verbose) {
+ printf("(size overrides at-time) ");
+ }
+ /* not returning here is how size overrides at-time */
+ } else if (ent->flags & CE_TRIMAT && !force && !rotatereq) {
diffsecs = ptimeget_diff(timenow, ent->trim_at);
if (diffsecs < 0.0) {
/* trim_at is some time in the future. */
--- diff.tmp ends here ---
>Release-Note:
>Audit-Trail:
>Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201109031740.p83HeVWS098843>
