Prevent runit from deleting own processing file

From: Andrew Stiegmann <andrew.stiegmann_at_gmail.com>
Date: Wed, 27 Mar 2024 17:15:54 -0800

Evening folks. Wanted to share a patch I recently put together to prevent
a runaway busyloop in svlogd when system time is far behind. It
effectively prevents svlogd from deleting the file its about to process,
which can happen when system time is far behind. Cheers.

diff --git a/src/svlogd.c b/src/svlogd.c
index 2e79219..d47fc47 100644
--- a/src/svlogd.c
+++ b/src/svlogd.c
_at__at_ -256,6 +256,10 _at__at_ void rmoldest(struct logdir *ld) {
         if (unlink(f->d_name) == -1)
           warn2("unable to unlink processor leftover", f->d_name);
       }
+ else if (!str_diff(ld->fnsave, f->d_name)) {
+ if (verbose)
+ strerr_warn5(INFO, "preserve: ", ld->name, "/", ld->fnsave, 0);
+ }
       else {
         ++n;
         if (str_diff(f->d_name, oldest) < 0) byte_copy(oldest, 27,
f->d_name);

-- 
Andrew AV. Stiegmann
Received on Thu Mar 28 2024 - 02:15:54 CET

This archive was generated by hypermail 2.4.0 : Thu Mar 28 2024 - 02:16:37 CET