Skip to content

Commit a6f6c7f

Browse files
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.
1 parent 16b005c commit a6f6c7f

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

master.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ static int open_log(const char *path)
8989

9090
log_fd = fd;
9191
rotate_log();
92+
log_written = (size_t)lseek(log_fd, 0, SEEK_CUR);
9293
return fd;
9394
}
9495

0 commit comments

Comments
 (0)