Repository navigation
Conversation
Zero log-buffer-size makes no sense. For discarding output, using "none" for log-type would be sufficient. Reject such settings, which would simplify later buffered-logging improvements, and mention this limitation in the manual,
- Restarting a service, whose log buffer ends with a correct EOL, should yield no empty line (duplicated newline) before the restarting message, i.e., "dinit: note: service restarted\n" shouldn't be prefixed with '\n'. - Restarting a service, whose log buffer is empty, should yield no restarting message at all.
Implement a circular log buffer in base_process_service. It provides the following functionality, - Copy data and append it to the buffer (log_buffer_append), possibly fails for allocation errors if the buffer fails to grow to log-buffer-size, which should be okay since the previous code fails in this case, too. - Linearize the buffer, so it could be randomly accessed by most external APIs (linearize_log_buffer). Comparing to the previous truncating implementation, appending to the buffer now requires an extra copy since the buffer couldn't be randomly written, but surrounding code gets simplified. Integration tests triggering buffer rotation are added along the way. Closes: davmac314#315
Wrap invocation of dinitctl in lambdas, to make the test cases easier to read.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This series implements a circular buffer for buffering service log, providing a simple API to append to it, and another in-place API to linearize the buffer to be sent to external programs, etc. Only appending to the buffer when it doesn't reach the maximum size might involve memory allocation. The new append API introduces extra overhead of copying, but is much easier to use, with which related code is simplified.
For sake of simplicity, the first patch modifies service loading code, to reject
log-buffer-size = 0settings. This possibly breaks existing services, but I don't think such settings make much sense, since it means all output from the service would be discarded, which could (and IMO, should) be achieved bylog-type = none.