summaryrefslogtreecommitdiff
path: root/support
diff options
context:
space:
mode:
authorEric Covener <covener@apache.org>2023-01-06 20:45:16 +0000
committerEric Covener <covener@apache.org>2023-01-06 20:45:16 +0000
commit43f0c91fd01fc2f1eed3cf8330f8a1b992b28a82 (patch)
tree501bf816e7c75de39214908b3a993bf6ab2e9381 /support
parent05297d7b00f0cb1f20d3ff14f4409097df2615fe (diff)
downloadhttpd-43f0c91fd01fc2f1eed3cf8330f8a1b992b28a82.tar.gz
minor tweak to -n with size rotation
Without -t, One line can be added to base "logfile" even when it's over the size limit already. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1906428 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'support')
-rw-r--r--support/rotatelogs.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/support/rotatelogs.c b/support/rotatelogs.c
index 3ebd67c1a6..5430f9e2e3 100644
--- a/support/rotatelogs.c
+++ b/support/rotatelogs.c
@@ -378,6 +378,7 @@ static void doRotate(rotate_config_t *config, rotate_status_t *status)
apr_status_t rv;
struct logfile newlog;
int thisLogNum = -1;
+ int oldreason = status->rotateReason;
/* Retrieve local-time-adjusted-Unix-time. */
now = get_now(config, &offset);
@@ -472,6 +473,19 @@ static void doRotate(rotate_config_t *config, rotate_status_t *status)
/* New log file is now 'current'. */
status->current = newlog;
+
+ /* The first write to to the initial file hasn't checked for size
+ * In the normalized timestamp case and the custom strftime case with
+ * any reasonable accuracy, it's futile as the rotation will pick the
+ * same filename again.
+ * For -n, when not truncating, check and rotate.
+ */
+ if (config->num_files > 0 && oldreason == ROTATE_NEW && !config->truncate) {
+ checkRotate(config, status);
+ if (status->rotateReason != ROTATE_NONE) {
+ doRotate(config, status);
+ }
+ }
}
else {
char *error = apr_psprintf(newlog.pool, "%pm", &rv);