Skip to content

Conversation

@Abhijeet94
Copy link

Description

Fixes log rotation reliability by ensuring rotation checks occur even during periods with no log traffic. Previously, log files would only rotate when writes occurred, causing unpredictable rotation timing during zero-traffic periods.

Main changes:

  • Background rotation thread: Periodically triggers rotation checks by calling Write("", 0) on registered contexts which helps during zero-traffic periods

  • Fixed double rotation bug: Ensured rotate_time is updated for both rotation_flag and interval-based rotations

  • Registration system: Added RegisterTimeBasedLogRotation() to manage contexts requiring time-based rotation checks

  • Skip I/O for empty buffers: Modified write functions to perform I/O only when buffer_len > 0, allowing rotation checks without actual writes

The solution reuses existing rotation mechanisms without duplicating logic, ensuring compatibility with all current rotation features (SIGHUP, rotate-interval, filename patterns).

Ticket: https://redmine.openinfosecfoundation.org/issues/8115

Testing -- tested on local setup and ensured the log files are rotating even when there is no traffic being processed by Suricata.

Make sure these boxes are checked accordingly before submitting your Pull Request -- thank you.

Contribution style:

Our Contribution agreements:

Changes (if applicable):

…iods

Description

Fixes time-based log rotation reliability by ensuring rotation checks occur even during periods with no log traffic. Previously, log files would only rotate when writes occurred, causing unpredictable rotation timing during zero-traffic periods.

Main changes:

- Background rotation thread: Periodically triggers rotation checks by calling Write("", 0) on registered contexts which helps during zero-traffic periods

- Fixed double rotation bug: Ensured rotate_time is updated for both rotation_flag and interval-based rotations

- Registration system: Added RegisterTimeBasedLogRotation() to manage contexts requiring time-based rotation checks

- Skip I/O for empty buffers: Modified write functions to perform I/O only when buffer_len > 0, allowing rotation checks without actual writes

The solution reuses existing rotation mechanisms without duplicating logic, ensuring compatibility with all current rotation features (SIGHUP, rotate-interval, filename patterns).

Ticket: OISF#8115
@github-actions
Copy link

NOTE: This PR may contain new authors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant