summaryrefslogtreecommitdiffstats
path: root/logd
diff options
context:
space:
mode:
authorArne H Juul <arnej@yahooinc.com>2021-12-10 13:33:51 +0000
committerArne H Juul <arnej@yahooinc.com>2021-12-10 13:33:51 +0000
commitdb86bee1d36f02977eff6e2b24b1ba9de3b4f42f (patch)
treeb89b714bdb6140a7dc77c01c9a361046bdc19fb4 /logd
parentc99b914f967b392cc72cba021f47fc18aea3f009 (diff)
check more often if we should remove old logs
Diffstat (limited to 'logd')
-rw-r--r--logd/src/logd/watcher.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/logd/src/logd/watcher.cpp b/logd/src/logd/watcher.cpp
index bab80dab7bd..23d1580dbf4 100644
--- a/logd/src/logd/watcher.cpp
+++ b/logd/src/logd/watcher.cpp
@@ -140,6 +140,7 @@ Watcher::watchfile()
vespalib::SigCatch catcher;
int sleepcount = 0;
vespalib::system_time created = vespalib::system_time::min();
+ vespalib::system_time lastPrune = vespalib::system_time::min();
again:
// XXX should close and/or check _wfd first ?
@@ -215,6 +216,11 @@ Watcher::watchfile()
bool wantrotate = (now > created + _confsubscriber.getRotateAge())
|| (sb.st_size > _confsubscriber.getRotateSize());
+ if (now > lastPrune + 61s) {
+ removeOldLogs(filename);
+ lastPrune = now;
+ }
+
if (rotate) {
vespalib::duration rotTime = rotTimer.elapsed();
off_t overflow_size = (1.1 * _confsubscriber.getRotateSize());
@@ -240,7 +246,6 @@ Watcher::watchfile()
LOG(warning, "logfile spamming %d times, aggressively removing %s", spamfill_counter, newfn);
unlink(newfn);
}
- removeOldLogs(filename);
goto again;
}
} else if (stat(filename, &sb) != 0