From a6f6c7f7632106d4121911d991fcfddf7a536e7b Mon Sep 17 00:00:00 2001 From: Ricardo Valfreixo Date: Thu, 12 Mar 2026 12:13:59 +0100 Subject: [PATCH] Fix log file growing to 2x configured cap log_written tracked bytes since last rotation, not actual file size. After open_log(), the file could already hold log_max_size bytes but log_written started at 0, so another log_max_size was written before rotation triggered. Initialize log_written from the fd position after rotate_log() so the counter reflects reality. --- master.c | 1 + 1 file changed, 1 insertion(+) diff --git a/master.c b/master.c index 05d3a04..b4b2f68 100644 --- a/master.c +++ b/master.c @@ -89,6 +89,7 @@ static int open_log(const char *path) log_fd = fd; rotate_log(); + log_written = (size_t)lseek(log_fd, 0, SEEK_CUR); return fd; }